Stage M7
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ContentType" AS ENUM ('PAGE', 'POST');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ContentStatus" AS ENUM ('DRAFT', 'PUBLISHED');
|
||||
|
||||
-- NOTE: Prisma's diff wanted to DROP INDEX "search_documents_document_idx" and
|
||||
-- ALTER "search_documents"."document" DROP DEFAULT here. Removed on purpose —
|
||||
-- `document` is a GENERATED tsvector column created by raw SQL in the M6
|
||||
-- migration, which Prisma's schema cannot express, so it proposes undoing it in
|
||||
-- every migration from now on. Applying it destroys full-text search.
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "content_entries" (
|
||||
"id" UUID NOT NULL,
|
||||
"type" "ContentType" NOT NULL,
|
||||
"status" "ContentStatus" NOT NULL DEFAULT 'DRAFT',
|
||||
"published_at" TIMESTAMPTZ(3),
|
||||
"cover_image_id" UUID,
|
||||
"author_user_id" UUID,
|
||||
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(3) NOT NULL,
|
||||
"deleted_at" TIMESTAMPTZ(3),
|
||||
|
||||
CONSTRAINT "content_entries_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "content_entry_translations" (
|
||||
"entry_id" UUID NOT NULL,
|
||||
"locale" "Locale" NOT NULL,
|
||||
"slug" VARCHAR(200) NOT NULL,
|
||||
"title" VARCHAR(255) NOT NULL,
|
||||
"excerpt" VARCHAR(500),
|
||||
"body" TEXT NOT NULL,
|
||||
"meta_title" VARCHAR(255),
|
||||
"meta_description" TEXT,
|
||||
|
||||
CONSTRAINT "content_entry_translations_pkey" PRIMARY KEY ("entry_id","locale")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "content_entries_type_status_published_at_idx" ON "content_entries"("type", "status", "published_at");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "content_entry_translations_locale_slug_key" ON "content_entry_translations"("locale", "slug");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "content_entries" ADD CONSTRAINT "content_entries_cover_image_id_fkey" FOREIGN KEY ("cover_image_id") REFERENCES "media_assets"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "content_entries" ADD CONSTRAINT "content_entries_author_user_id_fkey" FOREIGN KEY ("author_user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "content_entry_translations" ADD CONSTRAINT "content_entry_translations_entry_id_fkey" FOREIGN KEY ("entry_id") REFERENCES "content_entries"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user