import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres' export async function up({ db, payload, req }: MigrateUpArgs): Promise { await db.execute(sql` CREATE TYPE "public"."enum_posts_content_type" AS ENUM('note', 'tutorial', 'case_study', 'comparison'); CREATE TYPE "public"."enum_launch_notifications_source" AS ENUM('subscription'); CREATE TABLE "launch_notifications" ( "id" serial PRIMARY KEY NOT NULL, "email" varchar NOT NULL, "source" "enum_launch_notifications_source" DEFAULT 'subscription', "updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL, "created_at" timestamp(3) with time zone DEFAULT now() NOT NULL ); ALTER TABLE "posts" ADD COLUMN "content_type" "enum_posts_content_type"; ALTER TABLE "posts" ADD COLUMN "author_name" varchar; ALTER TABLE "posts" ADD COLUMN "source_id" varchar; ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "launch_notifications_id" integer; CREATE UNIQUE INDEX "launch_notifications_email_idx" ON "launch_notifications" USING btree ("email"); CREATE INDEX "launch_notifications_updated_at_idx" ON "launch_notifications" USING btree ("updated_at"); CREATE INDEX "launch_notifications_created_at_idx" ON "launch_notifications" USING btree ("created_at"); ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_launch_notifications_fk" FOREIGN KEY ("launch_notifications_id") REFERENCES "public"."launch_notifications"("id") ON DELETE cascade ON UPDATE no action; CREATE INDEX "posts_source_id_idx" ON "posts" USING btree ("source_id"); CREATE INDEX "payload_locked_documents_rels_launch_notifications_id_idx" ON "payload_locked_documents_rels" USING btree ("launch_notifications_id");`) } export async function down({ db, payload, req }: MigrateDownArgs): Promise { await db.execute(sql` ALTER TABLE "launch_notifications" DISABLE ROW LEVEL SECURITY; DROP TABLE "launch_notifications" CASCADE; ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_launch_notifications_fk"; DROP INDEX "posts_source_id_idx"; DROP INDEX "payload_locked_documents_rels_launch_notifications_id_idx"; ALTER TABLE "posts" DROP COLUMN "content_type"; ALTER TABLE "posts" DROP COLUMN "author_name"; ALTER TABLE "posts" DROP COLUMN "source_id"; ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "launch_notifications_id"; DROP TYPE "public"."enum_posts_content_type"; DROP TYPE "public"."enum_launch_notifications_source";`) }