feat: wip

This commit is contained in:
Ephraim Atta-Duncan
2023-09-11 09:45:03 +00:00
parent d4f6fa7dc4
commit 7b28ba968e
15 changed files with 902 additions and 8 deletions

View File

@ -0,0 +1,34 @@
-- CreateEnum
CREATE TYPE "TemplateType" AS ENUM ('PRIVATE', 'PUBLIC');
-- CreateTable
CREATE TABLE "Template" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"kind" "TemplateType" NOT NULL,
"ownerId" INTEGER NOT NULL,
"documentId" INTEGER NOT NULL,
CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "DocumentContent" (
"id" SERIAL NOT NULL,
"content" TEXT NOT NULL,
CONSTRAINT "DocumentContent_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Template_slug_key" ON "Template"("slug");
-- CreateIndex
CREATE INDEX "Template_ownerId_idx" ON "Template"("ownerId");
-- AddForeignKey
ALTER TABLE "Template" ADD CONSTRAINT "Template_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Template" ADD CONSTRAINT "Template_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "DocumentContent"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,21 @@
/*
Warnings:
- You are about to drop the `DocumentContent` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Template` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Template" DROP CONSTRAINT "Template_documentId_fkey";
-- DropForeignKey
ALTER TABLE "Template" DROP CONSTRAINT "Template_ownerId_fkey";
-- DropTable
DROP TABLE "DocumentContent";
-- DropTable
DROP TABLE "Template";
-- DropEnum
DROP TYPE "TemplateType";

View File

@ -0,0 +1,34 @@
-- CreateEnum
CREATE TYPE "TemplateType" AS ENUM ('PRIVATE', 'PUBLIC');
-- CreateTable
CREATE TABLE "Template" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"kind" "TemplateType" NOT NULL,
"ownerId" INTEGER NOT NULL,
"documentId" INTEGER NOT NULL,
CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "DocumentContent" (
"id" SERIAL NOT NULL,
"content" TEXT NOT NULL,
CONSTRAINT "DocumentContent_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Template_slug_key" ON "Template"("slug");
-- CreateIndex
CREATE INDEX "Template_ownerId_idx" ON "Template"("ownerId");
-- AddForeignKey
ALTER TABLE "Template" ADD CONSTRAINT "Template_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Template" ADD CONSTRAINT "Template_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "DocumentContent"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Template" ALTER COLUMN "kind" SET DEFAULT 'PRIVATE';

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Template" ADD COLUMN "description" TEXT;

View File

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