diff --git a/prisma/migrations/20231125101755_adding_template/migration.sql b/prisma/migrations/20231125101755_adding_template/migration.sql deleted file mode 100644 index f7ad0b6..0000000 --- a/prisma/migrations/20231125101755_adding_template/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "Site" ADD COLUMN "template" TEXT; diff --git a/prisma/migrations/20231127161333_make_better_env_vars/migration.sql b/prisma/migrations/20231127161333_make_better_env_vars/migration.sql deleted file mode 100644 index 2cc36d4..0000000 --- a/prisma/migrations/20231127161333_make_better_env_vars/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "Site" ALTER COLUMN "environmentVariables" SET DEFAULT '{"preview":{},"production":{}}'; diff --git a/prisma/migrations/20231130174816_change_name_to_project/migration.sql b/prisma/migrations/20231130174816_change_name_to_project/migration.sql deleted file mode 100644 index 7432302..0000000 --- a/prisma/migrations/20231130174816_change_name_to_project/migration.sql +++ /dev/null @@ -1,39 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Site` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropForeignKey -ALTER TABLE "Site" DROP CONSTRAINT "Site_userId_fkey"; - --- DropTable -DROP TABLE "Site"; - --- CreateTable -CREATE TABLE "Project" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "slug" TEXT NOT NULL, - "customDomain" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - "environmentVariables" JSONB NOT NULL DEFAULT '{"preview":{},"production":{}}', - "userId" TEXT, - "template" TEXT, - - CONSTRAINT "Project_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "Project_slug_key" ON "Project"("slug"); - --- CreateIndex -CREATE UNIQUE INDEX "Project_customDomain_key" ON "Project"("customDomain"); - --- CreateIndex -CREATE INDEX "Project_userId_idx" ON "Project"("userId"); - --- AddForeignKey -ALTER TABLE "Project" ADD CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20231202204817_removed_unused_roles/migration.sql b/prisma/migrations/20231202204817_removed_unused_roles/migration.sql deleted file mode 100644 index 0e5ff95..0000000 --- a/prisma/migrations/20231202204817_removed_unused_roles/migration.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* - Warnings: - - - The values [MANAGER,SUPPORT] on the enum `UserRole` will be removed. If these variants are still used in the database, this will fail. - -*/ --- AlterEnum -BEGIN; -CREATE TYPE "UserRole_new" AS ENUM ('ADMIN', 'USER'); -ALTER TABLE "User" ALTER COLUMN "role" DROP DEFAULT; -ALTER TABLE "User" ALTER COLUMN "role" TYPE "UserRole_new" USING ("role"::text::"UserRole_new"); -ALTER TYPE "UserRole" RENAME TO "UserRole_old"; -ALTER TYPE "UserRole_new" RENAME TO "UserRole"; -DROP TYPE "UserRole_old"; -ALTER TABLE "User" ALTER COLUMN "role" SET DEFAULT 'USER'; -COMMIT; diff --git a/prisma/migrations/20231123223637_init_new_platform/migration.sql b/prisma/migrations/20231215135725_init/migration.sql similarity index 73% rename from prisma/migrations/20231123223637_init_new_platform/migration.sql rename to prisma/migrations/20231215135725_init/migration.sql index c283614..fe9f6a4 100644 --- a/prisma/migrations/20231123223637_init_new_platform/migration.sql +++ b/prisma/migrations/20231215135725_init/migration.sql @@ -1,5 +1,5 @@ -- CreateEnum -CREATE TYPE "UserRole" AS ENUM ('ADMIN', 'MANAGER', 'USER', 'SUPPORT'); +CREATE TYPE "UserRole" AS ENUM ('ADMIN', 'USER'); -- CreateTable CREATE TABLE "User" ( @@ -55,7 +55,7 @@ CREATE TABLE "VerificationToken" ( ); -- CreateTable -CREATE TABLE "Site" ( +CREATE TABLE "Project" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "description" TEXT, @@ -63,10 +63,16 @@ CREATE TABLE "Site" ( "customDomain" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL, - "environmentVariables" JSONB NOT NULL DEFAULT '{}', - "userId" TEXT, + "environmentVariables" JSONB NOT NULL DEFAULT '{"preview":{},"production":{}}', + "template" TEXT, - CONSTRAINT "Site_pkey" PRIMARY KEY ("id") + CONSTRAINT "Project_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "_ProjectToUser" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL ); -- CreateIndex @@ -91,13 +97,16 @@ CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token" CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token"); -- CreateIndex -CREATE UNIQUE INDEX "Site_slug_key" ON "Site"("slug"); +CREATE UNIQUE INDEX "Project_slug_key" ON "Project"("slug"); -- CreateIndex -CREATE UNIQUE INDEX "Site_customDomain_key" ON "Site"("customDomain"); +CREATE UNIQUE INDEX "Project_customDomain_key" ON "Project"("customDomain"); -- CreateIndex -CREATE INDEX "Site_userId_idx" ON "Site"("userId"); +CREATE UNIQUE INDEX "_ProjectToUser_AB_unique" ON "_ProjectToUser"("A", "B"); + +-- CreateIndex +CREATE INDEX "_ProjectToUser_B_index" ON "_ProjectToUser"("B"); -- AddForeignKey ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; @@ -106,4 +115,7 @@ ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId" ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "Site" ADD CONSTRAINT "Site_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE "_ProjectToUser" ADD CONSTRAINT "_ProjectToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_ProjectToUser" ADD CONSTRAINT "_ProjectToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;