This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
api/prisma/migrations/20220321085102_initial/migration.sql

138 lines
4.6 KiB
MySQL
Raw Permalink Normal View History

2021-10-24 04:18:18 +02:00
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
2022-03-21 16:08:33 +01:00
"name" VARCHAR(30) NOT NULL,
"email" VARCHAR(254),
2021-10-24 04:18:18 +02:00
"password" TEXT,
"logo" TEXT,
2022-03-21 16:08:33 +01:00
"status" VARCHAR(50),
"biography" VARCHAR(160),
2021-10-24 04:18:18 +02:00
"website" VARCHAR(255),
"isConfirmed" BOOLEAN NOT NULL DEFAULT false,
"temporaryToken" TEXT,
"temporaryExpirationToken" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "UserSetting" (
"id" SERIAL NOT NULL,
2022-03-21 16:08:33 +01:00
"language" VARCHAR(10) NOT NULL DEFAULT E'en',
"theme" VARCHAR(10) NOT NULL DEFAULT E'dark',
2021-10-24 04:18:18 +02:00
"isPublicEmail" BOOLEAN NOT NULL DEFAULT false,
"isPublicGuilds" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" INTEGER NOT NULL,
CONSTRAINT "UserSetting_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "RefreshToken" (
"id" SERIAL NOT NULL,
"token" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" INTEGER NOT NULL,
CONSTRAINT "RefreshToken_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "OAuth" (
"id" SERIAL NOT NULL,
"providerId" TEXT NOT NULL,
2022-03-21 16:08:33 +01:00
"provider" VARCHAR(20) NOT NULL,
2021-10-24 04:18:18 +02:00
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" INTEGER NOT NULL,
CONSTRAINT "OAuth_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Member" (
"id" SERIAL NOT NULL,
"isOwner" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" INTEGER NOT NULL,
"guildId" INTEGER NOT NULL,
CONSTRAINT "Member_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Guild" (
"id" SERIAL NOT NULL,
2022-03-21 16:08:33 +01:00
"name" VARCHAR(30) NOT NULL,
2021-10-24 04:18:18 +02:00
"icon" TEXT,
"description" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Guild_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Channel" (
"id" SERIAL NOT NULL,
2022-03-21 16:08:33 +01:00
"name" VARCHAR(20) NOT NULL,
2021-10-24 04:18:18 +02:00
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"guildId" INTEGER NOT NULL,
CONSTRAINT "Channel_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Message" (
"id" SERIAL NOT NULL,
"value" TEXT NOT NULL,
2022-03-21 16:08:33 +01:00
"type" VARCHAR(10) NOT NULL DEFAULT E'text',
"mimetype" VARCHAR(127) NOT NULL DEFAULT E'text/plain',
2021-10-24 04:18:18 +02:00
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"memberId" INTEGER NOT NULL,
"channelId" INTEGER NOT NULL,
CONSTRAINT "Message_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "User_name_key" ON "User"("name");
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "UserSetting_userId_key" ON "UserSetting"("userId");
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "UserSetting" ADD CONSTRAINT "UserSetting_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "RefreshToken" ADD CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "OAuth" ADD CONSTRAINT "OAuth_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "Member" ADD CONSTRAINT "Member_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "Member" ADD CONSTRAINT "Member_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "Channel" ADD CONSTRAINT "Channel_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "Message" ADD CONSTRAINT "Message_memberId_fkey" FOREIGN KEY ("memberId") REFERENCES "Member"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2021-10-24 04:18:18 +02:00
-- AddForeignKey
2022-03-21 16:08:33 +01:00
ALTER TABLE "Message" ADD CONSTRAINT "Message_channelId_fkey" FOREIGN KEY ("channelId") REFERENCES "Channel"("id") ON DELETE CASCADE ON UPDATE CASCADE;