From 4bdda7dd7c16da77c9fa7783a52f50f5ffe5319f Mon Sep 17 00:00:00 2001 From: Piyush Garg Date: Mon, 9 Oct 2023 10:10:13 +0530 Subject: [PATCH] Resolve Migrations --- .../migration.sql | 26 ---- .../migration.sql | 32 ----- .../migration.sql | 42 ------ .../migration.sql | 8 -- .../migration.sql | 22 --- .../migration.sql | 3 - .../migration.sql | 20 --- .../migrations/20231009043955_/migration.sql | 132 ++++++++++++++++++ 8 files changed, 132 insertions(+), 153 deletions(-) delete mode 100644 prisma/migrations/20230812173406_added_users_table/migration.sql delete mode 100644 prisma/migrations/20230817130626_added_project_and_project_access_mapping/migration.sql delete mode 100644 prisma/migrations/20230909123009_create_forms_tables/migration.sql delete mode 100644 prisma/migrations/20230909130419_added_unique_form_slug/migration.sql delete mode 100644 prisma/migrations/20231008073028_add_custom_subdomain_to_project/migration.sql delete mode 100644 prisma/migrations/20231008135244_added_approve_tags_to_forms/migration.sql delete mode 100644 prisma/migrations/20231008144348_added_form_response_table/migration.sql create mode 100644 prisma/migrations/20231009043955_/migration.sql diff --git a/prisma/migrations/20230812173406_added_users_table/migration.sql b/prisma/migrations/20230812173406_added_users_table/migration.sql deleted file mode 100644 index 2d12ad1..0000000 --- a/prisma/migrations/20230812173406_added_users_table/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ --- CreateEnum -CREATE TYPE "AuthenticationType" AS ENUM ('EMAIL_PASSWORD', 'GOOGLE'); - --- CreateEnum -CREATE TYPE "UserRole" AS ENUM ('ADMIN', 'USER'); - --- CreateTable -CREATE TABLE "users" ( - "id" TEXT NOT NULL, - "first_name" TEXT NOT NULL, - "last_name" TEXT, - "email" TEXT NOT NULL, - "email_verified" BOOLEAN NOT NULL DEFAULT false, - "password" TEXT, - "salt" TEXT, - "authentication_type" "AuthenticationType" NOT NULL, - "profileImageURL" TEXT, - "role" "UserRole" NOT NULL DEFAULT 'USER', - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "users_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); diff --git a/prisma/migrations/20230817130626_added_project_and_project_access_mapping/migration.sql b/prisma/migrations/20230817130626_added_project_and_project_access_mapping/migration.sql deleted file mode 100644 index 6046fca..0000000 --- a/prisma/migrations/20230817130626_added_project_and_project_access_mapping/migration.sql +++ /dev/null @@ -1,32 +0,0 @@ --- CreateEnum -CREATE TYPE "ProjectAccessRole" AS ENUM ('OWNER', 'ADMIN'); - --- CreateTable -CREATE TABLE "projects" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "slug" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "projects_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "project_access_mapping" ( - "project_id" TEXT NOT NULL, - "user_id" TEXT NOT NULL, - "role" "ProjectAccessRole" NOT NULL DEFAULT 'OWNER' -); - --- CreateIndex -CREATE UNIQUE INDEX "projects_slug_key" ON "projects"("slug"); - --- CreateIndex -CREATE UNIQUE INDEX "project_access_mapping_project_id_user_id_key" ON "project_access_mapping"("project_id", "user_id"); - --- AddForeignKey -ALTER TABLE "project_access_mapping" ADD CONSTRAINT "project_access_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "project_access_mapping" ADD CONSTRAINT "project_access_mapping_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20230909123009_create_forms_tables/migration.sql b/prisma/migrations/20230909123009_create_forms_tables/migration.sql deleted file mode 100644 index 20206c1..0000000 --- a/prisma/migrations/20230909123009_create_forms_tables/migration.sql +++ /dev/null @@ -1,42 +0,0 @@ --- CreateTable -CREATE TABLE "forms" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "slug" TEXT NOT NULL, - "intro_title" TEXT NOT NULL, - "intro_message" TEXT, - "prompt_title" TEXT NOT NULL, - "prompt_description" TEXT, - "thankyou_title" TEXT NOT NULL, - "thankyou_message" TEXT, - "enable_cta" BOOLEAN NOT NULL DEFAULT false, - "cta_title" TEXT, - "cta_url" TEXT, - "project_id" TEXT NOT NULL, - "created_by" TEXT NOT NULL, - "is_active" BOOLEAN NOT NULL DEFAULT true, - "primary_color_hex_code" TEXT NOT NULL DEFAULT '#6701E6', - "background_color_hex_code" TEXT NOT NULL DEFAULT '#FFFFFF', - "lang" TEXT NOT NULL DEFAULT 'en', - "collect_video_testimonials" BOOLEAN NOT NULL DEFAULT false, - "collect_text_testimonials" BOOLEAN NOT NULL DEFAULT true, - "collect_ratings" BOOLEAN NOT NULL DEFAULT true, - "collect_images" BOOLEAN NOT NULL DEFAULT true, - "collect_email" BOOLEAN NOT NULL DEFAULT true, - "collect_job_title" BOOLEAN NOT NULL DEFAULT true, - "collect_user_image" BOOLEAN NOT NULL DEFAULT true, - "collect_website_url" BOOLEAN NOT NULL DEFAULT true, - "collect_company" BOOLEAN NOT NULL DEFAULT true, - "auto_approve_testimonials" BOOLEAN NOT NULL DEFAULT false, - "auto_add_tags" TEXT[] DEFAULT ARRAY[]::TEXT[], - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "forms_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "forms" ADD CONSTRAINT "forms_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "forms" ADD CONSTRAINT "forms_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20230909130419_added_unique_form_slug/migration.sql b/prisma/migrations/20230909130419_added_unique_form_slug/migration.sql deleted file mode 100644 index dc075fc..0000000 --- a/prisma/migrations/20230909130419_added_unique_form_slug/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[slug,project_id]` on the table `forms` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "forms_slug_project_id_key" ON "forms"("slug", "project_id"); diff --git a/prisma/migrations/20231008073028_add_custom_subdomain_to_project/migration.sql b/prisma/migrations/20231008073028_add_custom_subdomain_to_project/migration.sql deleted file mode 100644 index 140d38c..0000000 --- a/prisma/migrations/20231008073028_add_custom_subdomain_to_project/migration.sql +++ /dev/null @@ -1,22 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `slug` on the `projects` table. All the data in the column will be lost. - - A unique constraint covering the columns `[subdomain]` on the table `projects` will be added. If there are existing duplicate values, this will fail. - - A unique constraint covering the columns `[custom_domain]` on the table `projects` will be added. If there are existing duplicate values, this will fail. - - Added the required column `subdomain` to the `projects` table without a default value. This is not possible if the table is not empty. - -*/ --- DropIndex -DROP INDEX "projects_slug_key"; - --- AlterTable -ALTER TABLE "projects" DROP COLUMN "slug", -ADD COLUMN "custom_domain" TEXT, -ADD COLUMN "subdomain" TEXT NOT NULL; - --- CreateIndex -CREATE UNIQUE INDEX "projects_subdomain_key" ON "projects"("subdomain"); - --- CreateIndex -CREATE UNIQUE INDEX "projects_custom_domain_key" ON "projects"("custom_domain"); diff --git a/prisma/migrations/20231008135244_added_approve_tags_to_forms/migration.sql b/prisma/migrations/20231008135244_added_approve_tags_to_forms/migration.sql deleted file mode 100644 index efa3552..0000000 --- a/prisma/migrations/20231008135244_added_approve_tags_to_forms/migration.sql +++ /dev/null @@ -1,3 +0,0 @@ --- AlterTable -ALTER TABLE "form_responses" ADD COLUMN "approved" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "tags" TEXT[] DEFAULT ARRAY[]::TEXT[]; diff --git a/prisma/migrations/20231008144348_added_form_response_table/migration.sql b/prisma/migrations/20231008144348_added_form_response_table/migration.sql deleted file mode 100644 index a8e9f0b..0000000 --- a/prisma/migrations/20231008144348_added_form_response_table/migration.sql +++ /dev/null @@ -1,20 +0,0 @@ --- CreateTable -CREATE TABLE "form_responses" ( - "id" TEXT NOT NULL, - "form_id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "email" TEXT, - "image_url" TEXT, - "rating" INTEGER, - "testimonial" TEXT NOT NULL, - "job_title" TEXT, - "website_url" TEXT, - "company" TEXT, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "form_responses_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "form_responses" ADD CONSTRAINT "form_responses_form_id_fkey" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20231009043955_/migration.sql b/prisma/migrations/20231009043955_/migration.sql new file mode 100644 index 0000000..c1258a7 --- /dev/null +++ b/prisma/migrations/20231009043955_/migration.sql @@ -0,0 +1,132 @@ +-- CreateEnum +CREATE TYPE "AuthenticationType" AS ENUM ('EMAIL_PASSWORD', 'GOOGLE'); + +-- CreateEnum +CREATE TYPE "UserRole" AS ENUM ('ADMIN', 'USER'); + +-- CreateEnum +CREATE TYPE "ProjectAccessRole" AS ENUM ('OWNER', 'ADMIN'); + +-- CreateTable +CREATE TABLE "users" ( + "id" TEXT NOT NULL, + "first_name" TEXT NOT NULL, + "last_name" TEXT, + "email" TEXT NOT NULL, + "email_verified" BOOLEAN NOT NULL DEFAULT false, + "password" TEXT, + "salt" TEXT, + "authentication_type" "AuthenticationType" NOT NULL, + "profileImageURL" TEXT, + "role" "UserRole" NOT NULL DEFAULT 'USER', + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "users_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "projects" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "subdomain" TEXT NOT NULL, + "custom_domain" TEXT, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "projects_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "project_access_mapping" ( + "project_id" TEXT NOT NULL, + "user_id" TEXT NOT NULL, + "role" "ProjectAccessRole" NOT NULL DEFAULT 'OWNER' +); + +-- CreateTable +CREATE TABLE "forms" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "slug" TEXT NOT NULL, + "intro_title" TEXT NOT NULL, + "intro_message" TEXT, + "prompt_title" TEXT NOT NULL, + "prompt_description" TEXT, + "thankyou_title" TEXT NOT NULL, + "thankyou_message" TEXT, + "enable_cta" BOOLEAN NOT NULL DEFAULT false, + "cta_title" TEXT, + "cta_url" TEXT, + "project_id" TEXT NOT NULL, + "created_by" TEXT NOT NULL, + "is_active" BOOLEAN NOT NULL DEFAULT true, + "primary_color_hex_code" TEXT NOT NULL DEFAULT '#6701E6', + "background_color_hex_code" TEXT NOT NULL DEFAULT '#FFFFFF', + "lang" TEXT NOT NULL DEFAULT 'en', + "collect_video_testimonials" BOOLEAN NOT NULL DEFAULT false, + "collect_text_testimonials" BOOLEAN NOT NULL DEFAULT true, + "collect_ratings" BOOLEAN NOT NULL DEFAULT true, + "collect_images" BOOLEAN NOT NULL DEFAULT true, + "collect_email" BOOLEAN NOT NULL DEFAULT true, + "collect_job_title" BOOLEAN NOT NULL DEFAULT true, + "collect_user_image" BOOLEAN NOT NULL DEFAULT true, + "collect_website_url" BOOLEAN NOT NULL DEFAULT true, + "collect_company" BOOLEAN NOT NULL DEFAULT true, + "auto_approve_testimonials" BOOLEAN NOT NULL DEFAULT false, + "auto_add_tags" TEXT[] DEFAULT ARRAY[]::TEXT[], + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "forms_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "form_responses" ( + "id" TEXT NOT NULL, + "form_id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "email" TEXT, + "image_url" TEXT, + "rating" INTEGER, + "testimonial" TEXT NOT NULL, + "job_title" TEXT, + "website_url" TEXT, + "company" TEXT, + "tags" TEXT[] DEFAULT ARRAY[]::TEXT[], + "approved" BOOLEAN NOT NULL DEFAULT false, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "form_responses_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "users_email_key" ON "users"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "projects_subdomain_key" ON "projects"("subdomain"); + +-- CreateIndex +CREATE UNIQUE INDEX "projects_custom_domain_key" ON "projects"("custom_domain"); + +-- CreateIndex +CREATE UNIQUE INDEX "project_access_mapping_project_id_user_id_key" ON "project_access_mapping"("project_id", "user_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "forms_slug_project_id_key" ON "forms"("slug", "project_id"); + +-- AddForeignKey +ALTER TABLE "project_access_mapping" ADD CONSTRAINT "project_access_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "project_access_mapping" ADD CONSTRAINT "project_access_mapping_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "forms" ADD CONSTRAINT "forms_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "forms" ADD CONSTRAINT "forms_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "form_responses" ADD CONSTRAINT "form_responses_form_id_fkey" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE RESTRICT ON UPDATE CASCADE;