From 396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b Mon Sep 17 00:00:00 2001
From: Fuwn <50817549+Fuwn@users.noreply.github.com>
Date: Sat, 24 Jan 2026 13:09:50 +0000
Subject: Initial commit

Created from https://vercel.com/new
---
 .../02_report_schema_session_data/migration.sql    | 70 ++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 prisma/migrations/02_report_schema_session_data/migration.sql

(limited to 'prisma/migrations/02_report_schema_session_data/migration.sql')

diff --git a/prisma/migrations/02_report_schema_session_data/migration.sql b/prisma/migrations/02_report_schema_session_data/migration.sql
new file mode 100644
index 0000000..5fe6ef9
--- /dev/null
+++ b/prisma/migrations/02_report_schema_session_data/migration.sql
@@ -0,0 +1,70 @@
+-- AlterTable
+ALTER TABLE "event_data" RENAME COLUMN "event_data_type" TO "data_type";
+ALTER TABLE "event_data" RENAME COLUMN "event_date_value" TO "date_value";
+ALTER TABLE "event_data" RENAME COLUMN "event_id" TO "event_data_id";
+ALTER TABLE "event_data" RENAME COLUMN "event_numeric_value" TO "number_value";
+ALTER TABLE "event_data" RENAME COLUMN "event_string_value" TO "string_value";
+
+-- CreateTable
+CREATE TABLE "session_data" (
+    "session_data_id" UUID NOT NULL,
+    "website_id" UUID NOT NULL,
+    "session_id" UUID NOT NULL,
+    "session_key" VARCHAR(500) NOT NULL,
+    "string_value" VARCHAR(500),
+    "number_value" DECIMAL(19,4),
+    "date_value" TIMESTAMPTZ(6),
+    "data_type" INTEGER NOT NULL,
+    "created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
+    "deleted_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
+
+    CONSTRAINT "session_data_pkey" PRIMARY KEY ("session_data_id")
+);
+
+-- CreateTable
+CREATE TABLE "report" (
+    "report_id" UUID NOT NULL,
+    "user_id" UUID NOT NULL,
+    "website_id" UUID NOT NULL,
+    "type" VARCHAR(200) NOT NULL,
+    "name" VARCHAR(200) NOT NULL,
+    "description" VARCHAR(500) NOT NULL,
+    "parameters" VARCHAR(6000) NOT NULL,
+    "created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
+    "updated_at" TIMESTAMPTZ(6),
+
+    CONSTRAINT "report_pkey" PRIMARY KEY ("report_id")
+);
+
+-- CreateIndex
+CREATE INDEX "session_data_created_at_idx" ON "session_data"("created_at");
+
+-- CreateIndex
+CREATE INDEX "session_data_website_id_idx" ON "session_data"("website_id");
+
+-- CreateIndex
+CREATE INDEX "session_data_session_id_idx" ON "session_data"("session_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "report_report_id_key" ON "report"("report_id");
+
+-- CreateIndex
+CREATE INDEX "report_user_id_idx" ON "report"("user_id");
+
+-- CreateIndex
+CREATE INDEX "report_website_id_idx" ON "report"("website_id");
+
+-- CreateIndex
+CREATE INDEX "report_type_idx" ON "report"("type");
+
+-- CreateIndex
+CREATE INDEX "report_name_idx" ON "report"("name");
+
+-- EventData migration
+UPDATE "event_data"
+SET string_value = number_value
+WHERE data_type = 2;
+
+UPDATE "event_data"
+SET string_value = CONCAT(REPLACE(TO_CHAR(date_value, 'YYYY-MM-DD HH24:MI:SS'), ' ', 'T'), 'Z')
+WHERE data_type = 4;
\ No newline at end of file
-- 
cgit v1.2.3

