Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

add mysql 02 migration

Francis Cao1038a54fe4c4
diff --git a/db/mysql/migrations/02_report_schema/migration.sql b/db/mysql/migrations/02_report_schema/migration.sql
new file mode 100644
index 000000000..0476e9f7a
--- /dev/null
+++ b/db/mysql/migrations/02_report_schema/migration.sql
@@ -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;
diff --git a/db/mysql/schema.prisma b/db/mysql/schema.prisma
index 6455c8c09..0752f4183 100644
--- a/db/mysql/schema.prisma
+++ b/db/mysql/schema.prisma
@@ -19,6 +19,7 @@ model User {
website Website[]
teamUser TeamUser[]
+ Report Report[]
@@map("user")
}
@@ -59,6 +60,7 @@ model Website {
user User? @relation(fields: [userId], references: [id])
teamWebsite TeamWebsite[]
eventData EventData[]
+ Report Report[]
@@index([userId])
@@index([createdAt])
@@ -155,3 +157,24 @@ model TeamWebsite {
@@index([websiteId])
@@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")
+}
\ No newline at end of file