(database): add migration files for prisma

This commit is contained in:
Anthony 2022-07-25 02:13:27 +01:00
parent f369c2f108
commit c06d880f56
14 changed files with 411 additions and 3 deletions

3
.gitignore vendored
View File

@ -105,6 +105,3 @@ dist
# IntelliJ IDEA # IntelliJ IDEA
/.idea/ /.idea/
# Prisma migration files
/prisma/migrations/

View File

@ -0,0 +1,7 @@
-- CreateTable
CREATE TABLE "user" (
"id" INTEGER NOT NULL,
"vegan" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
);

View File

@ -0,0 +1,10 @@
/*
Warnings:
- The primary key for the `user` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- AlterTable
ALTER TABLE "user" DROP CONSTRAINT "user_pkey",
ALTER COLUMN "id" SET DATA TYPE VARCHAR(255),
ADD CONSTRAINT "user_pkey" PRIMARY KEY ("id");

View File

@ -0,0 +1,67 @@
/*
Warnings:
- You are about to drop the `user` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
DROP TABLE "user";
-- CreateTable
CREATE TABLE "User" (
"id" VARCHAR(255) NOT NULL,
"level" INTEGER NOT NULL DEFAULT 0,
"xp" INTEGER NOT NULL DEFAULT 0,
"balance" INTEGER NOT NULL DEFAULT 0,
"lastDaily" TIMESTAMP(3) NOT NULL,
"vegan" BOOLEAN NOT NULL DEFAULT false,
"activist" BOOLEAN NOT NULL DEFAULT false,
"trusted" BOOLEAN NOT NULL DEFAULT false,
"plus" BOOLEAN NOT NULL DEFAULT false,
"muted" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Restrict" (
"id" SERIAL NOT NULL,
"userId" TEXT NOT NULL,
"startTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"endedTime" TIMESTAMP(3),
"reason" TEXT NOT NULL,
CONSTRAINT "Restrict_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Ban" (
"id" SERIAL NOT NULL,
"userId" TEXT NOT NULL,
"time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"active" BOOLEAN NOT NULL DEFAULT true,
"reason" TEXT NOT NULL,
CONSTRAINT "Ban_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "TempBan" (
"id" SERIAL NOT NULL,
"userId" TEXT NOT NULL,
"startTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"endedTime" TIMESTAMP(3) NOT NULL,
"active" BOOLEAN NOT NULL DEFAULT true,
"reason" TEXT NOT NULL,
CONSTRAINT "TempBan_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "lastDaily" DROP NOT NULL;

View File

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "convinced" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN "vegCurious" BOOLEAN NOT NULL DEFAULT false;

View File

@ -0,0 +1,61 @@
/*
Warnings:
- Added the required column `modId` to the `Ban` table without a default value. This is not possible if the table is not empty.
- Added the required column `modId` to the `Restrict` table without a default value. This is not possible if the table is not empty.
- Added the required column `modId` to the `TempBan` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Ban" ADD COLUMN "modId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "Restrict" ADD COLUMN "modId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "TempBan" ADD COLUMN "modId" TEXT NOT NULL;
-- CreateTable
CREATE TABLE "Verify" (
"id" SERIAL NOT NULL,
"userId" TEXT NOT NULL,
"verifierId" TEXT,
"time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"timedOut" BOOLEAN NOT NULL DEFAULT false,
"vegan" BOOLEAN NOT NULL DEFAULT false,
"text" BOOLEAN NOT NULL DEFAULT false,
"serverVegan" BOOLEAN NOT NULL DEFAULT false,
"notes" TEXT,
CONSTRAINT "Verify_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Sus" (
"id" SERIAL NOT NULL,
"userId" TEXT NOT NULL,
"modId" TEXT NOT NULL,
CONSTRAINT "Sus_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_verifierId_fkey" FOREIGN KEY ("verifierId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `note` to the `Sus` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Sus" ADD COLUMN "note" TEXT NOT NULL;

View File

@ -0,0 +1,86 @@
/*
Warnings:
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Ban" DROP CONSTRAINT "Ban_modId_fkey";
-- DropForeignKey
ALTER TABLE "Ban" DROP CONSTRAINT "Ban_userId_fkey";
-- DropForeignKey
ALTER TABLE "Restrict" DROP CONSTRAINT "Restrict_modId_fkey";
-- DropForeignKey
ALTER TABLE "Restrict" DROP CONSTRAINT "Restrict_userId_fkey";
-- DropForeignKey
ALTER TABLE "Sus" DROP CONSTRAINT "Sus_modId_fkey";
-- DropForeignKey
ALTER TABLE "Sus" DROP CONSTRAINT "Sus_userId_fkey";
-- DropForeignKey
ALTER TABLE "TempBan" DROP CONSTRAINT "TempBan_modId_fkey";
-- DropForeignKey
ALTER TABLE "TempBan" DROP CONSTRAINT "TempBan_userId_fkey";
-- DropForeignKey
ALTER TABLE "Verify" DROP CONSTRAINT "Verify_userId_fkey";
-- DropForeignKey
ALTER TABLE "Verify" DROP CONSTRAINT "Verify_verifierId_fkey";
-- DropTable
DROP TABLE "User";
-- CreateTable
CREATE TABLE "Users" (
"id" VARCHAR(255) NOT NULL,
"level" INTEGER NOT NULL DEFAULT 0,
"xp" INTEGER NOT NULL DEFAULT 0,
"balance" INTEGER NOT NULL DEFAULT 0,
"lastDaily" TIMESTAMP(3),
"vegan" BOOLEAN NOT NULL DEFAULT false,
"trusted" BOOLEAN NOT NULL DEFAULT false,
"activist" BOOLEAN NOT NULL DEFAULT false,
"plus" BOOLEAN NOT NULL DEFAULT false,
"vegCurious" BOOLEAN NOT NULL DEFAULT false,
"convinced" BOOLEAN NOT NULL DEFAULT false,
"muted" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "Users_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_verifierId_fkey" FOREIGN KEY ("verifierId") REFERENCES "Users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_modId_fkey" FOREIGN KEY ("modId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_modId_fkey" FOREIGN KEY ("modId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_modId_fkey" FOREIGN KEY ("modId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_modId_fkey" FOREIGN KEY ("modId") REFERENCES "Users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,86 @@
/*
Warnings:
- You are about to drop the `Users` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Ban" DROP CONSTRAINT "Ban_modId_fkey";
-- DropForeignKey
ALTER TABLE "Ban" DROP CONSTRAINT "Ban_userId_fkey";
-- DropForeignKey
ALTER TABLE "Restrict" DROP CONSTRAINT "Restrict_modId_fkey";
-- DropForeignKey
ALTER TABLE "Restrict" DROP CONSTRAINT "Restrict_userId_fkey";
-- DropForeignKey
ALTER TABLE "Sus" DROP CONSTRAINT "Sus_modId_fkey";
-- DropForeignKey
ALTER TABLE "Sus" DROP CONSTRAINT "Sus_userId_fkey";
-- DropForeignKey
ALTER TABLE "TempBan" DROP CONSTRAINT "TempBan_modId_fkey";
-- DropForeignKey
ALTER TABLE "TempBan" DROP CONSTRAINT "TempBan_userId_fkey";
-- DropForeignKey
ALTER TABLE "Verify" DROP CONSTRAINT "Verify_userId_fkey";
-- DropForeignKey
ALTER TABLE "Verify" DROP CONSTRAINT "Verify_verifierId_fkey";
-- DropTable
DROP TABLE "Users";
-- CreateTable
CREATE TABLE "User" (
"uid" VARCHAR(255) NOT NULL,
"level" INTEGER NOT NULL DEFAULT 0,
"xp" INTEGER NOT NULL DEFAULT 0,
"balance" INTEGER NOT NULL DEFAULT 0,
"lastDaily" TIMESTAMP(3),
"vegan" BOOLEAN NOT NULL DEFAULT false,
"trusted" BOOLEAN NOT NULL DEFAULT false,
"activist" BOOLEAN NOT NULL DEFAULT false,
"plus" BOOLEAN NOT NULL DEFAULT false,
"vegCurious" BOOLEAN NOT NULL DEFAULT false,
"convinced" BOOLEAN NOT NULL DEFAULT false,
"muted" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "User_pkey" PRIMARY KEY ("uid")
);
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_verifierId_fkey" FOREIGN KEY ("verifierId") REFERENCES "User"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("uid") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,73 @@
/*
Warnings:
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `uid` on the `User` table. All the data in the column will be lost.
- Added the required column `id` to the `User` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "Ban" DROP CONSTRAINT "Ban_modId_fkey";
-- DropForeignKey
ALTER TABLE "Ban" DROP CONSTRAINT "Ban_userId_fkey";
-- DropForeignKey
ALTER TABLE "Restrict" DROP CONSTRAINT "Restrict_modId_fkey";
-- DropForeignKey
ALTER TABLE "Restrict" DROP CONSTRAINT "Restrict_userId_fkey";
-- DropForeignKey
ALTER TABLE "Sus" DROP CONSTRAINT "Sus_modId_fkey";
-- DropForeignKey
ALTER TABLE "Sus" DROP CONSTRAINT "Sus_userId_fkey";
-- DropForeignKey
ALTER TABLE "TempBan" DROP CONSTRAINT "TempBan_modId_fkey";
-- DropForeignKey
ALTER TABLE "TempBan" DROP CONSTRAINT "TempBan_userId_fkey";
-- DropForeignKey
ALTER TABLE "Verify" DROP CONSTRAINT "Verify_userId_fkey";
-- DropForeignKey
ALTER TABLE "Verify" DROP CONSTRAINT "Verify_verifierId_fkey";
-- AlterTable
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
DROP COLUMN "uid",
ADD COLUMN "id" VARCHAR(255) NOT NULL,
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id");
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Verify" ADD CONSTRAINT "Verify_verifierId_fkey" FOREIGN KEY ("verifierId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Sus" ADD CONSTRAINT "Sus_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Restrict" ADD CONSTRAINT "Restrict_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Ban" ADD CONSTRAINT "Ban_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "TempBan" ADD CONSTRAINT "TempBan_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Sus" ADD COLUMN "active" BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN "time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "notVegan" BOOLEAN NOT NULL DEFAULT false;

View File

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"