add psql migration
This commit is contained in:
parent
0cb28e9fde
commit
cbeefe733f
|
@ -3,6 +3,7 @@ CREATE TABLE umami.website_event
|
|||
(
|
||||
website_id UUID,
|
||||
session_id UUID,
|
||||
visit_id UUID,
|
||||
event_id UUID,
|
||||
--sessions
|
||||
hostname LowCardinality(String),
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "website_event" ADD COLUMN "session_id" UUID NULL;
|
||||
|
||||
UPDATE "website_event"
|
||||
SET session_id = uuid_in(overlay(overlay(md5(CONCAT(session_id::text, to_char(date_trunc('hour', created_at), 'YYYY-MM-DD HH24:00:00'))) placing '4' from 13) placing '8' from 17)::cstring)
|
||||
WHERE session_id IS NULL;
|
||||
|
||||
ALTER TABLE "website_event" ALTER COLUMN "session_id" SET NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_event_visit_id_idx" ON "website_event"("visit_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_event_website_id_visit_id_created_at_idx" ON "website_event"("website_id", "visit_id", "created_at");
|
|
@ -92,6 +92,7 @@ model WebsiteEvent {
|
|||
id String @id() @map("event_id") @db.Uuid
|
||||
websiteId String @map("website_id") @db.Uuid
|
||||
sessionId String @map("session_id") @db.Uuid
|
||||
visitId String @map("visit_id") @db.Uuid
|
||||
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
urlPath String @map("url_path") @db.VarChar(500)
|
||||
urlQuery String? @map("url_query") @db.VarChar(500)
|
||||
|
@ -107,6 +108,7 @@ model WebsiteEvent {
|
|||
|
||||
@@index([createdAt])
|
||||
@@index([sessionId])
|
||||
@@index([visitId])
|
||||
@@index([websiteId])
|
||||
@@index([websiteId, createdAt])
|
||||
@@index([websiteId, createdAt, urlPath])
|
||||
|
@ -115,6 +117,7 @@ model WebsiteEvent {
|
|||
@@index([websiteId, createdAt, pageTitle])
|
||||
@@index([websiteId, createdAt, eventName])
|
||||
@@index([websiteId, sessionId, createdAt])
|
||||
@@index([websiteId, visitId, createdAt])
|
||||
@@map("website_event")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue