From 3b3e357c27db3048e12abd7ceebd9d1dad28da65 Mon Sep 17 00:00:00 2001 From: viniciuscosmome <48590313+viniciuscosmome@users.noreply.github.com> Date: Fri, 10 Nov 2023 03:15:08 -0300 Subject: [PATCH] chore: remove functions from db --- .../20230618214820_setup/migration.sql | 32 ----- .../migration.sql | 27 ---- .../migrations/20230626145634_/migration.sql | 16 --- .../migrations/20230629223840_/migration.sql | 8 -- .../migrations/20230629233735_/migration.sql | 8 -- .../migration.sql | 2 - .../migration.sql | 2 - .../migrations/20230814205213_/migration.sql | 18 --- .../migrations/20230814220259_/migration.sql | 32 ----- .../migrations/20230816192752_/migration.sql | 12 -- .../migrations/20230818210820_/migration.sql | 27 ---- .../migrations/20231004195435_/migration.sql | 24 ---- .../migration.sql | 128 ++++++++++++++++++ 13 files changed, 128 insertions(+), 208 deletions(-) delete mode 100644 prisma/migrations/20230618214820_setup/migration.sql delete mode 100644 prisma/migrations/20230620193039_sessions_model/migration.sql delete mode 100644 prisma/migrations/20230626145634_/migration.sql delete mode 100644 prisma/migrations/20230629223840_/migration.sql delete mode 100644 prisma/migrations/20230629233735_/migration.sql delete mode 100644 prisma/migrations/20230701205249_account_permissions/migration.sql delete mode 100644 prisma/migrations/20230703104927_remember_session/migration.sql delete mode 100644 prisma/migrations/20230814205213_/migration.sql delete mode 100644 prisma/migrations/20230814220259_/migration.sql delete mode 100644 prisma/migrations/20230816192752_/migration.sql delete mode 100644 prisma/migrations/20230818210820_/migration.sql delete mode 100644 prisma/migrations/20231004195435_/migration.sql create mode 100644 prisma/migrations/20231110061420_initial_setup/migration.sql diff --git a/prisma/migrations/20230618214820_setup/migration.sql b/prisma/migrations/20230618214820_setup/migration.sql deleted file mode 100644 index 3de7291..0000000 --- a/prisma/migrations/20230618214820_setup/migration.sql +++ /dev/null @@ -1,32 +0,0 @@ --- CreateTable -CREATE TABLE "accounts" ( - "id" TEXT NOT NULL, - "email" TEXT NOT NULL, - "password" TEXT NOT NULL, - "verified_at" TIMESTAMP(3), - "accepted_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "accounts_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "profiles" ( - "id" SERIAL NOT NULL, - "name" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - "account_id" TEXT NOT NULL, - - CONSTRAINT "profiles_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "accounts_email_key" ON "accounts"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "profiles_account_id_key" ON "profiles"("account_id"); - --- AddForeignKey -ALTER TABLE "profiles" ADD CONSTRAINT "profiles_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230620193039_sessions_model/migration.sql b/prisma/migrations/20230620193039_sessions_model/migration.sql deleted file mode 100644 index b063c7e..0000000 --- a/prisma/migrations/20230620193039_sessions_model/migration.sql +++ /dev/null @@ -1,27 +0,0 @@ --- AlterTable -ALTER TABLE "accounts" ADD COLUMN "permissions" TEXT[] DEFAULT ARRAY['common']::TEXT[]; - --- CreateTable -CREATE TABLE "sessions" ( - "id" SERIAL NOT NULL, - "session_token" TEXT NOT NULL, - "refresh_token" TEXT NOT NULL, - "name" TEXT NOT NULL, - "account_id" TEXT NOT NULL, - "permissions" TEXT[], - "session_expires_in" TIMESTAMP(3) NOT NULL, - "refresh_expires_in" TIMESTAMP(3) NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "sessions_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "sessions_session_token_key" ON "sessions"("session_token"); - --- CreateIndex -CREATE UNIQUE INDEX "sessions_refresh_token_key" ON "sessions"("refresh_token"); - --- AddForeignKey -ALTER TABLE "sessions" ADD CONSTRAINT "sessions_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230626145634_/migration.sql b/prisma/migrations/20230626145634_/migration.sql deleted file mode 100644 index 64fbd3f..0000000 --- a/prisma/migrations/20230626145634_/migration.sql +++ /dev/null @@ -1,16 +0,0 @@ --- CreateTable -CREATE TABLE "ResetPasswordToken" ( - "id" SERIAL NOT NULL, - "token" TEXT NOT NULL, - "account_id" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "expireAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "ResetPasswordToken_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "ResetPasswordToken_account_id_key" ON "ResetPasswordToken"("account_id"); - --- AddForeignKey -ALTER TABLE "ResetPasswordToken" ADD CONSTRAINT "ResetPasswordToken_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20230629223840_/migration.sql b/prisma/migrations/20230629223840_/migration.sql deleted file mode 100644 index 47e33c9..0000000 --- a/prisma/migrations/20230629223840_/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `expireAt` on the `ResetPasswordToken` table. All the data in the column will be lost. - -*/ --- AlterTable -ALTER TABLE "ResetPasswordToken" DROP COLUMN "expireAt"; diff --git a/prisma/migrations/20230629233735_/migration.sql b/prisma/migrations/20230629233735_/migration.sql deleted file mode 100644 index a6fbcb3..0000000 --- a/prisma/migrations/20230629233735_/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[token]` on the table `ResetPasswordToken` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "ResetPasswordToken_token_key" ON "ResetPasswordToken"("token"); diff --git a/prisma/migrations/20230701205249_account_permissions/migration.sql b/prisma/migrations/20230701205249_account_permissions/migration.sql deleted file mode 100644 index 7216bd3..0000000 --- a/prisma/migrations/20230701205249_account_permissions/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "accounts" ALTER COLUMN "permissions" DROP DEFAULT; diff --git a/prisma/migrations/20230703104927_remember_session/migration.sql b/prisma/migrations/20230703104927_remember_session/migration.sql deleted file mode 100644 index 11b1759..0000000 --- a/prisma/migrations/20230703104927_remember_session/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "sessions" ADD COLUMN "remember" BOOLEAN NOT NULL DEFAULT false; diff --git a/prisma/migrations/20230814205213_/migration.sql b/prisma/migrations/20230814205213_/migration.sql deleted file mode 100644 index 7f5ad78..0000000 --- a/prisma/migrations/20230814205213_/migration.sql +++ /dev/null @@ -1,18 +0,0 @@ --- CreateEnum -CREATE TYPE "TaskPriorities" AS ENUM ('LOW', 'MEDIUM', 'HIGH', 'URGENT'); - --- CreateEnum -CREATE TYPE "TaskTags" AS ENUM ('PERSONAL', 'STUDY', 'FINANCE', 'CAREER', 'HEALTH'); - --- CreateTable -CREATE TABLE "Task" ( - "id" SERIAL NOT NULL, - "name" TEXT NOT NULL, - "date" DATE NOT NULL, - "hour" TIME NOT NULL, - "description" TEXT NOT NULL, - "priority" "TaskPriorities" NOT NULL, - "tag" "TaskTags" NOT NULL, - - CONSTRAINT "Task_pkey" PRIMARY KEY ("id") -); diff --git a/prisma/migrations/20230814220259_/migration.sql b/prisma/migrations/20230814220259_/migration.sql deleted file mode 100644 index aaedbe0..0000000 --- a/prisma/migrations/20230814220259_/migration.sql +++ /dev/null @@ -1,32 +0,0 @@ -/* - Warnings: - - - The values [LOW,MEDIUM,HIGH,URGENT] on the enum `TaskPriorities` will be removed. If these variants are still used in the database, this will fail. - - The values [PERSONAL,STUDY,FINANCE,CAREER,HEALTH] on the enum `TaskTags` will be removed. If these variants are still used in the database, this will fail. - - You are about to drop the column `date` on the `Task` table. All the data in the column will be lost. - - You are about to drop the column `hour` on the `Task` table. All the data in the column will be lost. - - Added the required column `deadline` to the `Task` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterEnum -BEGIN; -CREATE TYPE "TaskPriorities_new" AS ENUM ('low', 'medium', 'high', 'urgent'); -ALTER TABLE "Task" ALTER COLUMN "priority" TYPE "TaskPriorities_new" USING ("priority"::text::"TaskPriorities_new"); -ALTER TYPE "TaskPriorities" RENAME TO "TaskPriorities_old"; -ALTER TYPE "TaskPriorities_new" RENAME TO "TaskPriorities"; -DROP TYPE "TaskPriorities_old"; -COMMIT; - --- AlterEnum -BEGIN; -CREATE TYPE "TaskTags_new" AS ENUM ('personal', 'study', 'finance', 'career', 'health'); -ALTER TABLE "Task" ALTER COLUMN "tag" TYPE "TaskTags_new" USING ("tag"::text::"TaskTags_new"); -ALTER TYPE "TaskTags" RENAME TO "TaskTags_old"; -ALTER TYPE "TaskTags_new" RENAME TO "TaskTags"; -DROP TYPE "TaskTags_old"; -COMMIT; - --- AlterTable -ALTER TABLE "Task" DROP COLUMN "date", -DROP COLUMN "hour", -ADD COLUMN "deadline" TIMESTAMP(3) NOT NULL; diff --git a/prisma/migrations/20230816192752_/migration.sql b/prisma/migrations/20230816192752_/migration.sql deleted file mode 100644 index 41f2a5b..0000000 --- a/prisma/migrations/20230816192752_/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `deadline` on the `Task` table. All the data in the column will be lost. - - Added the required column `date` to the `Task` table without a default value. This is not possible if the table is not empty. - - Added the required column `hour` to the `Task` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE "Task" DROP COLUMN "deadline", -ADD COLUMN "date" DATE NOT NULL, -ADD COLUMN "hour" TIME NOT NULL; diff --git a/prisma/migrations/20230818210820_/migration.sql b/prisma/migrations/20230818210820_/migration.sql deleted file mode 100644 index b8a2eae..0000000 --- a/prisma/migrations/20230818210820_/migration.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Task` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropTable -DROP TABLE "Task"; - --- CreateTable -CREATE TABLE "tasks" ( - "id" SERIAL NOT NULL, - "name" TEXT NOT NULL, - "hour" TIME NOT NULL, - "date" DATE NOT NULL, - "description" TEXT NOT NULL, - "priority" "TaskPriorities" NOT NULL, - "tag" "TaskTags" NOT NULL, - "account_id" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "tasks_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "tasks" ADD CONSTRAINT "tasks_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20231004195435_/migration.sql b/prisma/migrations/20231004195435_/migration.sql deleted file mode 100644 index 8130935..0000000 --- a/prisma/migrations/20231004195435_/migration.sql +++ /dev/null @@ -1,24 +0,0 @@ --- CreateEnum -CREATE TYPE "GoalPeriodicity" AS ENUM ('daily', 'weekly', 'biweekly', 'monthly', 'bimonthly'); - --- CreateEnum -CREATE TYPE "GoalType" AS ENUM ('personal', 'profissional'); - --- CreateTable -CREATE TABLE "goals" ( - "id" SERIAL NOT NULL, - "description" TEXT NOT NULL, - "goal" TEXT NOT NULL, - "start_date" DATE NOT NULL, - "end_date" DATE NOT NULL, - "periodicity" "GoalPeriodicity" NOT NULL, - "type" "GoalType" NOT NULL, - "account_id" TEXT NOT NULL, - "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updated_at" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "goals_pkey" PRIMARY KEY ("id") -); - --- AddForeignKey -ALTER TABLE "goals" ADD CONSTRAINT "goals_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20231110061420_initial_setup/migration.sql b/prisma/migrations/20231110061420_initial_setup/migration.sql new file mode 100644 index 0000000..339cc77 --- /dev/null +++ b/prisma/migrations/20231110061420_initial_setup/migration.sql @@ -0,0 +1,128 @@ +-- CreateEnum +CREATE TYPE "GoalPeriodicity" AS ENUM ('daily', 'weekly', 'biweekly', 'monthly', 'bimonthly'); + +-- CreateEnum +CREATE TYPE "GoalType" AS ENUM ('personal', 'profissional'); + +-- CreateEnum +CREATE TYPE "TaskPriorities" AS ENUM ('low', 'medium', 'high', 'urgent'); + +-- CreateEnum +CREATE TYPE "TaskTags" AS ENUM ('personal', 'study', 'finance', 'career', 'health'); + +-- CreateTable +CREATE TABLE "accounts" ( + "id" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password" TEXT NOT NULL, + "permissions" TEXT[], + "verified_at" TIMESTAMP(3), + "accepted_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "accounts_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ResetPasswordToken" ( + "id" SERIAL NOT NULL, + "token" TEXT NOT NULL, + "account_id" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ResetPasswordToken_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "profiles" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + "account_id" TEXT NOT NULL, + + CONSTRAINT "profiles_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "sessions" ( + "id" SERIAL NOT NULL, + "session_token" TEXT NOT NULL, + "refresh_token" TEXT NOT NULL, + "account_id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "permissions" TEXT[], + "remember" BOOLEAN NOT NULL DEFAULT false, + "session_expires_in" TIMESTAMP(3) NOT NULL, + "refresh_expires_in" TIMESTAMP(3) NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "sessions_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "tasks" ( + "id" SERIAL NOT NULL, + "name" TEXT NOT NULL, + "hour" TIME NOT NULL, + "date" DATE NOT NULL, + "description" TEXT NOT NULL, + "priority" "TaskPriorities" NOT NULL, + "tag" "TaskTags" NOT NULL, + "account_id" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "tasks_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "goals" ( + "id" SERIAL NOT NULL, + "description" TEXT NOT NULL, + "goal" TEXT NOT NULL, + "start_date" DATE NOT NULL, + "end_date" DATE NOT NULL, + "periodicity" "GoalPeriodicity" NOT NULL, + "type" "GoalType" NOT NULL, + "account_id" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "goals_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "accounts_email_key" ON "accounts"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResetPasswordToken_token_key" ON "ResetPasswordToken"("token"); + +-- CreateIndex +CREATE UNIQUE INDEX "ResetPasswordToken_account_id_key" ON "ResetPasswordToken"("account_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "profiles_account_id_key" ON "profiles"("account_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "sessions_session_token_key" ON "sessions"("session_token"); + +-- CreateIndex +CREATE UNIQUE INDEX "sessions_refresh_token_key" ON "sessions"("refresh_token"); + +-- AddForeignKey +ALTER TABLE "ResetPasswordToken" ADD CONSTRAINT "ResetPasswordToken_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "profiles" ADD CONSTRAINT "profiles_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "sessions" ADD CONSTRAINT "sessions_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "tasks" ADD CONSTRAINT "tasks_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "goals" ADD CONSTRAINT "goals_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "accounts"("id") ON DELETE RESTRICT ON UPDATE CASCADE;