From 595afc3bfd7d803b3f15d8bd7a1e20766e8d24ab Mon Sep 17 00:00:00 2001 From: Olaf Rosendahl Date: Fri, 17 Nov 2023 11:58:07 +0100 Subject: [PATCH] fix: save full timestamp --- .../migration.sql | 18 ++++++++++ .../migration.sql | 36 +++++++++++++++++++ web/prisma/schema.prisma | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 web/prisma/migrations/20231117105636_drop_new_pageviews/migration.sql create mode 100644 web/prisma/migrations/20231117105705_recreate_new_pageviews/migration.sql diff --git a/web/prisma/migrations/20231117105636_drop_new_pageviews/migration.sql b/web/prisma/migrations/20231117105636_drop_new_pageviews/migration.sql new file mode 100644 index 0000000..5e331d6 --- /dev/null +++ b/web/prisma/migrations/20231117105636_drop_new_pageviews/migration.sql @@ -0,0 +1,18 @@ +/* + Warnings: + + - You are about to drop the `Location` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `PageViewNext` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "PageViewNext" DROP CONSTRAINT "PageViewNext_locationId_fkey"; + +-- DropForeignKey +ALTER TABLE "PageViewNext" DROP CONSTRAINT "PageViewNext_projectId_fkey"; + +-- DropTable +DROP TABLE "Location"; + +-- DropTable +DROP TABLE "PageViewNext"; diff --git a/web/prisma/migrations/20231117105705_recreate_new_pageviews/migration.sql b/web/prisma/migrations/20231117105705_recreate_new_pageviews/migration.sql new file mode 100644 index 0000000..ee45d84 --- /dev/null +++ b/web/prisma/migrations/20231117105705_recreate_new_pageviews/migration.sql @@ -0,0 +1,36 @@ +-- CreateTable +CREATE TABLE "PageViewNext" ( + "id" UUID NOT NULL, + "date" TIMESTAMP(3) NOT NULL, + "pathname" TEXT NOT NULL, + "user_hash" TEXT NOT NULL, + "referrer" TEXT, + "browser" TEXT, + "device" TEXT, + "os" TEXT, + "locationId" INTEGER NOT NULL, + "projectId" TEXT NOT NULL, + + CONSTRAINT "PageViewNext_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Location" ( + "id" SERIAL NOT NULL, + "flag" TEXT NOT NULL, + "country" TEXT NOT NULL, + "city" TEXT NOT NULL, + "latitude" DOUBLE PRECISION NOT NULL, + "longitude" DOUBLE PRECISION NOT NULL, + + CONSTRAINT "Location_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Location_flag_country_city_key" ON "Location"("flag", "country", "city"); + +-- AddForeignKey +ALTER TABLE "PageViewNext" ADD CONSTRAINT "PageViewNext_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PageViewNext" ADD CONSTRAINT "PageViewNext_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/web/prisma/schema.prisma b/web/prisma/schema.prisma index 2f6c32e..9f17de6 100644 --- a/web/prisma/schema.prisma +++ b/web/prisma/schema.prisma @@ -103,7 +103,7 @@ model PageVisitor { model PageViewNext { id String @id @default(uuid()) @db.Uuid - date DateTime @db.Date + date DateTime pathname String user_hash String referrer String?