mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
This commit is contained in:
parent
b6013c3ee8
commit
889a404650
3 changed files with 61 additions and 2 deletions
41
prisma/migrations/15_add_share/migration.sql
Normal file
41
prisma/migrations/15_add_share/migration.sql
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "share" (
|
||||||
|
"share_id" UUID NOT NULL,
|
||||||
|
"entity_id" UUID NOT NULL,
|
||||||
|
"share_type" INTEGER NOT NULL,
|
||||||
|
"share_code" VARCHAR(50),
|
||||||
|
"parameters" JSONB NOT NULL,
|
||||||
|
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updated_at" TIMESTAMPTZ(6),
|
||||||
|
|
||||||
|
CONSTRAINT "share_pkey" PRIMARY KEY ("share_id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "share_share_id_key" ON "share"("share_id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "share_share_code_key" ON "share"("share_code");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "share_entity_id_idx" ON "share"("entity_id");
|
||||||
|
|
||||||
|
-- MigrateData
|
||||||
|
INSERT INTO "share" (share_id, entity_id, share_type, share_code, parameters, created_at)
|
||||||
|
SELECT gen_random_uuid(),
|
||||||
|
website_id,
|
||||||
|
1,
|
||||||
|
share_id,
|
||||||
|
'{}'::jsonb,
|
||||||
|
now()
|
||||||
|
FROM "website"
|
||||||
|
WHERE share_id IS NOT NULL;
|
||||||
|
|
||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "website_share_id_idx";
|
||||||
|
|
||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "website_share_id_key";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "website" DROP COLUMN "share_id";
|
||||||
|
|
@ -67,7 +67,6 @@ model Website {
|
||||||
id String @id @unique @map("website_id") @db.Uuid
|
id String @id @unique @map("website_id") @db.Uuid
|
||||||
name String @db.VarChar(100)
|
name String @db.VarChar(100)
|
||||||
domain String? @db.VarChar(500)
|
domain String? @db.VarChar(500)
|
||||||
shareId String? @unique @map("share_id") @db.VarChar(50)
|
|
||||||
resetAt DateTime? @map("reset_at") @db.Timestamptz(6)
|
resetAt DateTime? @map("reset_at") @db.Timestamptz(6)
|
||||||
userId String? @map("user_id") @db.Uuid
|
userId String? @map("user_id") @db.Uuid
|
||||||
teamId String? @map("team_id") @db.Uuid
|
teamId String? @map("team_id") @db.Uuid
|
||||||
|
|
@ -88,7 +87,6 @@ model Website {
|
||||||
@@index([userId])
|
@@index([userId])
|
||||||
@@index([teamId])
|
@@index([teamId])
|
||||||
@@index([createdAt])
|
@@index([createdAt])
|
||||||
@@index([shareId])
|
|
||||||
@@index([createdBy])
|
@@index([createdBy])
|
||||||
@@map("website")
|
@@map("website")
|
||||||
}
|
}
|
||||||
|
|
@ -316,3 +314,16 @@ model Pixel {
|
||||||
@@index([createdAt])
|
@@index([createdAt])
|
||||||
@@map("pixel")
|
@@map("pixel")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model Share {
|
||||||
|
id String @id() @unique() @map("share_id") @db.Uuid
|
||||||
|
entityId String @map("entity_id") @db.Uuid
|
||||||
|
shareType Int @map("share_type") @db.Integer
|
||||||
|
shareCode String? @unique @map("share_code") @db.VarChar(50)
|
||||||
|
parameters Json
|
||||||
|
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
|
updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||||
|
|
||||||
|
@@index([entityId])
|
||||||
|
@@map("share")
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,13 @@ export const EVENT_TYPE = {
|
||||||
pixelEvent: 4,
|
pixelEvent: 4,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const ENTITY_TYPE = {
|
||||||
|
website: 1,
|
||||||
|
link: 2,
|
||||||
|
pixel: 3,
|
||||||
|
board: 4,
|
||||||
|
} as const;
|
||||||
|
|
||||||
export const DATA_TYPE = {
|
export const DATA_TYPE = {
|
||||||
string: 1,
|
string: 1,
|
||||||
number: 2,
|
number: 2,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue