update
This commit is contained in:
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `user_devices` table. If the table is not empty, all the data it contains will be lost.
|
||||
- A unique constraint covering the columns `[tracking_code]` on the table `charged_license_transactions` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `tracking_code` to the `charged_license_transactions` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE `user_devices`;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `consumer_devices` (
|
||||
`uuid` VARCHAR(255) NOT NULL,
|
||||
`app_version` VARCHAR(20) NOT NULL,
|
||||
`build_number` VARCHAR(20) NOT NULL,
|
||||
`platform` VARCHAR(100) NOT NULL,
|
||||
`brand` VARCHAR(100) NOT NULL,
|
||||
`model` VARCHAR(100) NOT NULL,
|
||||
`device` VARCHAR(100) NOT NULL,
|
||||
`os_version` VARCHAR(20) NOT NULL,
|
||||
`sdk_version` VARCHAR(20) NOT NULL,
|
||||
`release_number` VARCHAR(20) NOT NULL,
|
||||
`browser_name` VARCHAR(100) NULL,
|
||||
`fcm_token` VARCHAR(100) NULL,
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
`consumer_id` VARCHAR(191) NOT NULL,
|
||||
UNIQUE INDEX `consumer_devices_uuid_key` (`uuid`),
|
||||
PRIMARY KEY (`uuid`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `application_released_info` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`version` VARCHAR(191) NOT NULL,
|
||||
`build_number` VARCHAR(191) NOT NULL,
|
||||
`is_stable` BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
`is_minimum_supported` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
`type` ENUM('ANDROID', 'IOS') NOT NULL,
|
||||
`notes` JSON NULL,
|
||||
`release_date` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`created_at` TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
`updated_at` TIMESTAMP(0) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `consumer_devices`
|
||||
ADD CONSTRAINT `consumer_devices_consumer_id_fkey` FOREIGN KEY (`consumer_id`) REFERENCES `consumers` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `charged_license_transactions`
|
||||
ADD COLUMN `tracking_code` VARCHAR(191) NULL;
|
||||
|
||||
UPDATE `charged_license_transactions`
|
||||
SET
|
||||
`tracking_code` = CONCAT(
|
||||
'TRX-',
|
||||
UPPER(
|
||||
REPLACE (`id`, '-', '')
|
||||
)
|
||||
)
|
||||
WHERE
|
||||
`tracking_code` IS NULL
|
||||
OR `tracking_code` = '';
|
||||
|
||||
ALTER TABLE `charged_license_transactions`
|
||||
MODIFY `tracking_code` VARCHAR(191) NOT NULL;
|
||||
|
||||
CREATE UNIQUE INDEX `charged_license_transactions_tracking_code_key` ON `charged_license_transactions` (`tracking_code`);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `is_stable` on the `application_released_info` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `type` on the `application_released_info` table. All the data in the column will be lost.
|
||||
- Added the required column `platform` to the `application_released_info` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `release_type` to the `application_released_info` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `publisher` to the `consumer_devices` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `application_released_info` DROP COLUMN `is_stable`,
|
||||
DROP COLUMN `type`,
|
||||
ADD COLUMN `platform` ENUM('ANDROID', 'IOS') NOT NULL,
|
||||
ADD COLUMN `release_type` ENUM('STABLE', 'BETA', 'ALPHA') NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `consumer_devices` ADD COLUMN `publisher` ENUM('DIRECT', 'CAFE_BAZAR', 'MAYKET') NOT NULL,
|
||||
ADD COLUMN `user_agent` VARCHAR(100) NULL;
|
||||
@@ -30,6 +30,7 @@ model Consumer {
|
||||
consumer_accounts ConsumerAccount[]
|
||||
business_activities BusinessActivity[]
|
||||
activated_licenses ActivatedLicense[]
|
||||
consumer_devices ConsumerDevices[]
|
||||
|
||||
@@map("consumers")
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ model ActivatedLicense {
|
||||
model ChargedLicenseTransactions {
|
||||
id String @id @default(uuid())
|
||||
activation_expires_at DateTime
|
||||
tracking_code String @unique()
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
model ConsumerDevices {
|
||||
uuid String @id @unique() @db.VarChar(255)
|
||||
app_version String @db.VarChar(20)
|
||||
build_number String @db.VarChar(20)
|
||||
platform String @db.VarChar(100)
|
||||
brand String @db.VarChar(100)
|
||||
model String @db.VarChar(100)
|
||||
device String @db.VarChar(100)
|
||||
publisher ApplicationPublisher
|
||||
os_version String @db.VarChar(20)
|
||||
sdk_version String @db.VarChar(20)
|
||||
release_number String @db.VarChar(20)
|
||||
user_agent String? @db.VarChar(100)
|
||||
browser_name String? @db.VarChar(100)
|
||||
fcm_token String? @db.VarChar(100)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
consumer_id String
|
||||
consumer Consumer @relation(fields: [consumer_id], references: [id])
|
||||
|
||||
@@map("consumer_devices")
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
model ApplicationReleasedInfo {
|
||||
id String @id @default(uuid())
|
||||
version String
|
||||
build_number String
|
||||
is_minimum_supported Boolean @default(false)
|
||||
release_type ApplicationReleaseType
|
||||
platform ApplicationPlatform
|
||||
notes Json?
|
||||
|
||||
release_date DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
@@map("application_released_info")
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
model UserDevices {
|
||||
account_id String? @db.VarChar(255)
|
||||
app_version String @db.VarChar(20)
|
||||
build_number String @db.VarChar(20)
|
||||
|
||||
uuid String @id @unique() @db.VarChar(255)
|
||||
platform String @db.VarChar(100)
|
||||
brand String @db.VarChar(100)
|
||||
model String @db.VarChar(100)
|
||||
device String @db.VarChar(100)
|
||||
os_version String @db.VarChar(20)
|
||||
sdk_version String @db.VarChar(20)
|
||||
release_number String @db.VarChar(20)
|
||||
browser_name String? @db.VarChar(100)
|
||||
fcm_token String? @db.VarChar(100)
|
||||
|
||||
@@map("user_devices")
|
||||
}
|
||||
@@ -133,3 +133,20 @@ enum TokenType {
|
||||
ACCESS
|
||||
REFRESH
|
||||
}
|
||||
|
||||
enum ApplicationPlatform {
|
||||
ANDROID
|
||||
IOS
|
||||
}
|
||||
|
||||
enum ApplicationReleaseType {
|
||||
STABLE
|
||||
BETA
|
||||
ALPHA
|
||||
}
|
||||
|
||||
enum ApplicationPublisher {
|
||||
DIRECT
|
||||
CAFE_BAZAR
|
||||
MAYKET
|
||||
}
|
||||
|
||||
@@ -335,6 +335,7 @@ async function main() {
|
||||
const transaction = await tx.chargedLicenseTransactions.create({
|
||||
data: {
|
||||
activation_expires_at: startOfToday,
|
||||
tracking_code: `LIC-${'random'}`,
|
||||
partner: {
|
||||
connect: {
|
||||
id: partner.id,
|
||||
|
||||
Reference in New Issue
Block a user