2024-03-21 17:30:42 +01:00
|
|
|
-- AlterTable
|
2024-03-21 17:36:27 +01:00
|
|
|
ALTER TABLE "website_event" ADD COLUMN "visit_id" UUID NULL;
|
2024-03-21 17:30:42 +01:00
|
|
|
|
|
|
|
UPDATE "website_event"
|
2024-03-21 17:36:27 +01:00
|
|
|
SET visit_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 visit_id IS NULL;
|
2024-03-21 17:30:42 +01:00
|
|
|
|
2024-03-21 17:36:27 +01:00
|
|
|
ALTER TABLE "website_event" ALTER COLUMN "visit_id" SET NOT NULL;
|
2024-03-21 17:30:42 +01:00
|
|
|
|
|
|
|
-- CreateIndex
|
|
|
|
CREATE INDEX "website_event_visit_id_idx" ON "website_event"("visit_id");
|
|
|
|
|
|
|
|
-- CreateIndex
|
2024-03-21 17:36:27 +01:00
|
|
|
CREATE INDEX "website_event_website_id_visit_id_created_at_idx" ON "website_event"("website_id", "visit_id", "created_at");
|