mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
squash 01_init postgresql
This commit is contained in:
parent
a22d50a597
commit
f984d80c42
@ -1,6 +1,3 @@
|
||||
-- CreateExtension
|
||||
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "user" (
|
||||
"user_id" UUID NOT NULL,
|
||||
@ -25,6 +22,9 @@ CREATE TABLE "session" (
|
||||
"screen" VARCHAR(11),
|
||||
"language" VARCHAR(35),
|
||||
"country" CHAR(2),
|
||||
"subdivision1" CHAR(3),
|
||||
"subdivision2" VARCHAR(50),
|
||||
"city" VARCHAR(50),
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "session_pkey" PRIMARY KEY ("session_id")
|
||||
@ -35,10 +35,9 @@ CREATE TABLE "website" (
|
||||
"website_id" UUID NOT NULL,
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"domain" VARCHAR(500),
|
||||
"share_id" VARCHAR(64),
|
||||
"rev_id" INTEGER NOT NULL DEFAULT 0,
|
||||
"share_id" VARCHAR(50),
|
||||
"reset_at" TIMESTAMPTZ(6),
|
||||
"user_id" UUID,
|
||||
"team_id" UUID,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(6),
|
||||
"deleted_at" TIMESTAMPTZ(6),
|
||||
@ -52,23 +51,40 @@ CREATE TABLE "website_event" (
|
||||
"website_id" UUID NOT NULL,
|
||||
"session_id" UUID NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
"url" VARCHAR(500) NOT NULL,
|
||||
"referrer" VARCHAR(500),
|
||||
"url_path" VARCHAR(500) NOT NULL,
|
||||
"url_query" VARCHAR(500),
|
||||
"referrer_path" VARCHAR(500),
|
||||
"referrer_query" VARCHAR(500),
|
||||
"referrer_domain" VARCHAR(500),
|
||||
"page_title" VARCHAR(500),
|
||||
"event_type" INTEGER NOT NULL DEFAULT 1,
|
||||
"event_name" VARCHAR(50),
|
||||
"event_data" JSONB,
|
||||
|
||||
CONSTRAINT "website_event_pkey" PRIMARY KEY ("event_id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "event_data" (
|
||||
"event_id" UUID NOT NULL,
|
||||
"website_id" UUID NOT NULL,
|
||||
"website_event_id" UUID NOT NULL,
|
||||
"event_key" VARCHAR(500) NOT NULL,
|
||||
"event_string_value" VARCHAR(500),
|
||||
"event_numeric_value" DECIMAL(19,4),
|
||||
"event_date_value" TIMESTAMPTZ(6),
|
||||
"event_data_type" INTEGER NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "event_data_pkey" PRIMARY KEY ("event_id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "team" (
|
||||
"team_id" UUID NOT NULL,
|
||||
"name" VARCHAR(50) NOT NULL,
|
||||
"user_id" UUID NOT NULL,
|
||||
"access_code" VARCHAR(50),
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(6),
|
||||
"deleted_at" TIMESTAMPTZ(6),
|
||||
|
||||
CONSTRAINT "team_pkey" PRIMARY KEY ("team_id")
|
||||
);
|
||||
@ -81,11 +97,20 @@ CREATE TABLE "team_user" (
|
||||
"role" VARCHAR(50) NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(6),
|
||||
"deleted_at" TIMESTAMPTZ(6),
|
||||
|
||||
CONSTRAINT "team_user_pkey" PRIMARY KEY ("team_user_id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "team_website" (
|
||||
"team_website_id" UUID NOT NULL,
|
||||
"team_id" UUID NOT NULL,
|
||||
"website_id" UUID NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "team_website_pkey" PRIMARY KEY ("team_website_id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "user_user_id_key" ON "user"("user_id");
|
||||
|
||||
@ -107,6 +132,9 @@ CREATE UNIQUE INDEX "website_website_id_key" ON "website"("website_id");
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "website_share_id_key" ON "website"("share_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_user_id_idx" ON "website"("user_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_created_at_idx" ON "website"("created_at");
|
||||
|
||||
@ -128,23 +156,41 @@ CREATE INDEX "website_event_website_id_created_at_idx" ON "website_event"("websi
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_event_website_id_session_id_created_at_idx" ON "website_event"("website_id", "session_id", "created_at");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "event_data_created_at_idx" ON "event_data"("created_at");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "event_data_website_id_idx" ON "event_data"("website_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "event_data_website_event_id_idx" ON "event_data"("website_event_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "team_team_id_key" ON "team"("team_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "team_access_code_key" ON "team"("access_code");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_access_code_idx" ON "team"("access_code");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "team_user_team_user_id_key" ON "team_user"("team_user_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "website" ADD CONSTRAINT "website_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "team"("team_id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_user_team_id_idx" ON "team_user"("team_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "website" ADD CONSTRAINT "website_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_user_user_id_idx" ON "team_user"("user_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "team"("team_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "team_website_team_website_id_key" ON "team_website"("team_website_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "team_user" ADD CONSTRAINT "team_user_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("user_id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_website_team_id_idx" ON "team_website"("team_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_website_website_id_idx" ON "team_website"("website_id");
|
||||
|
||||
-- AddSystemUser
|
||||
INSERT INTO "user" (user_id, username, role, password) VALUES ('41e2b680-648e-4b09-bcd7-3e2b10c06264' , 'admin', 'admin', '$2b$10$BUli0c.muyCW1ErNJc3jL.vFRFtFJWrT8/GcR4A.sUdCznaXiqFXa');
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to alter the column `share_id` on the `website` table. The data in that column could be lost. The data in that column will be cast from `VarChar(64)` to `VarChar(50)`.
|
||||
- A unique constraint covering the columns `[access_code]` on the table `team` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "team" ADD COLUMN "access_code" VARCHAR(50);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "website" ALTER COLUMN "share_id" SET DATA TYPE VARCHAR(50);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "team_access_code_key" ON "team"("access_code");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_user_id_idx" ON "team"("user_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_access_code_idx" ON "team"("access_code");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_user_team_id_idx" ON "team_user"("team_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_user_user_id_idx" ON "team_user"("user_id");
|
@ -1,17 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "team_user" DROP CONSTRAINT "team_user_team_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "team_user" DROP CONSTRAINT "team_user_user_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "website" DROP CONSTRAINT "website_team_id_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "website" DROP CONSTRAINT "website_user_id_fkey";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_team_id_idx" ON "website"("team_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "website_user_id_idx" ON "website"("user_id");
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `deleted_at` on the `team` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `deleted_at` on the `team_user` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `team_id` on the `website` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "website_team_id_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "team" DROP COLUMN "deleted_at";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "team_user" DROP COLUMN "deleted_at";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "website" DROP COLUMN "team_id";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "team_website" (
|
||||
"team_website_id" UUID NOT NULL,
|
||||
"team_id" UUID NOT NULL,
|
||||
"user_id" UUID NOT NULL,
|
||||
"website_id" UUID NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "team_website_pkey" PRIMARY KEY ("team_website_id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "team_website_team_website_id_key" ON "team_website"("team_website_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_website_team_id_idx" ON "team_website"("team_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_website_user_id_idx" ON "team_website"("user_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "team_website_website_id_idx" ON "team_website"("website_id");
|
@ -1,7 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "session" ADD COLUMN "city" VARCHAR(50),
|
||||
ADD COLUMN "subdivision1" CHAR(3),
|
||||
ADD COLUMN "subdivision2" VARCHAR(50);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "website_event" ADD COLUMN "page_title" VARCHAR(500);
|
@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `event_data` on the `website_event` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "website_event" DROP COLUMN "event_data";
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `user_id` on the `team` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `user_id` on the `team_website` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- DropIndex
|
||||
DROP INDEX "team_user_id_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "team_website_user_id_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "team" DROP COLUMN "user_id";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "team_website" DROP COLUMN "user_id";
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `referrer` on the `website_event` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `url` on the `website_event` table. All the data in the column will be lost.
|
||||
- Added the required column `url_path` to the `website_event` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "website_event" DROP COLUMN "referrer",
|
||||
DROP COLUMN "url",
|
||||
ADD COLUMN "referrer_domain" VARCHAR(500),
|
||||
ADD COLUMN "referrer_path" VARCHAR(500),
|
||||
ADD COLUMN "referrer_query" VARCHAR(500),
|
||||
ADD COLUMN "url_path" VARCHAR(500) NOT NULL,
|
||||
ADD COLUMN "url_query" VARCHAR(500);
|
@ -1,23 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "event_data" (
|
||||
"event_id" UUID NOT NULL,
|
||||
"website_id" UUID NOT NULL,
|
||||
"website_event_id" UUID NOT NULL,
|
||||
"event_key" VARCHAR(500) NOT NULL,
|
||||
"event_string_value" VARCHAR(500),
|
||||
"event_numeric_value" DECIMAL(19,4),
|
||||
"event_date_value" TIMESTAMPTZ(6),
|
||||
"event_data_type" INTEGER NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "event_data_pkey" PRIMARY KEY ("event_id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "event_data_created_at_idx" ON "event_data"("created_at");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "event_data_website_id_idx" ON "event_data"("website_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "event_data_website_event_id_idx" ON "event_data"("website_event_id");
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `rev_id` on the `website` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "website" DROP COLUMN "rev_id",
|
||||
ADD COLUMN "reset_at" TIMESTAMPTZ(6);
|
Loading…
Reference in New Issue
Block a user