add mysql 02 migration

This commit is contained in:
Francis Cao 2023-05-31 12:01:16 -07:00
parent 77f758205b
commit 1038a54fe4
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,19 @@
-- CreateTable
CREATE TABLE `report` (
`report_id` VARCHAR(36) NOT NULL,
`user_id` VARCHAR(36) NOT NULL,
`website_id` VARCHAR(36) NOT NULL,
`type` VARCHAR(200) NOT NULL,
`name` VARCHAR(200) NOT NULL,
`description` VARCHAR(500) NOT NULL,
`parameters` VARCHAR(6000) NOT NULL,
`created_at` TIMESTAMP(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`updated_at` TIMESTAMP(0) NULL,
UNIQUE INDEX `report_report_id_key`(`report_id`),
INDEX `report_user_id_idx`(`user_id`),
INDEX `report_website_id_idx`(`website_id`),
INDEX `report_type_idx`(`type`),
INDEX `report_name_idx`(`name`),
PRIMARY KEY (`report_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -19,6 +19,7 @@ model User {
website Website[] website Website[]
teamUser TeamUser[] teamUser TeamUser[]
Report Report[]
@@map("user") @@map("user")
} }
@ -59,6 +60,7 @@ model Website {
user User? @relation(fields: [userId], references: [id]) user User? @relation(fields: [userId], references: [id])
teamWebsite TeamWebsite[] teamWebsite TeamWebsite[]
eventData EventData[] eventData EventData[]
Report Report[]
@@index([userId]) @@index([userId])
@@index([createdAt]) @@index([createdAt])
@ -155,3 +157,24 @@ model TeamWebsite {
@@index([websiteId]) @@index([websiteId])
@@map("team_website") @@map("team_website")
} }
model Report {
id String @id() @unique() @map("report_id") @db.VarChar(36)
userId String @map("user_id") @db.VarChar(36)
websiteId String @map("website_id") @db.VarChar(36)
type String @map("type") @db.VarChar(200)
name String @map("name") @db.VarChar(200)
description String @map("description") @db.VarChar(500)
parameters String @map("parameters") @db.VarChar(6000)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0)
user User @relation(fields: [userId], references: [id])
website Website @relation(fields: [websiteId], references: [id])
@@index([userId])
@@index([websiteId])
@@index([type])
@@index([name])
@@map("report")
}