import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'

export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
  await db.execute(sql`
   CREATE TYPE "public"."enum_pages_blocks_text_width" AS ENUM('1/2', '3/4');
  CREATE TYPE "public"."enum_pages_blocks_title_size" AS ENUM('xl', 'lg', 'md', 'sm');
  CREATE TYPE "public"."enum_pages_blocks_title_align" AS ENUM('left', 'center');
  CREATE TYPE "public"."enum_pages_blocks_section_background_color" AS ENUM('none', 'soft', 'off-white');
  CREATE TYPE "public"."enum_pages_blocks_section_padding" AS ENUM('small', 'medium', 'large');
  CREATE TYPE "public"."enum_pages_blocks_banner_background_position" AS ENUM('center center', 'top center', 'bottom center', 'center left', 'center right', 'top left', 'top right', 'bottom left', 'bottom right');
  CREATE TYPE "public"."enum_pages_blocks_banner_background_size" AS ENUM('cover', 'contain', 'auto');
  CREATE TYPE "public"."enum_pages_blocks_horizontal_rule_color" AS ENUM('base', 'shade1', 'shade2', 'shade3', 'contrast', 'contrastShade1');
  CREATE TYPE "public"."enum_pages_blocks_collapsible_image_with_text_background_color" AS ENUM('none', 'soft', 'off-white');
  CREATE TYPE "public"."enum_pages_blocks_collapsible_image_with_text_schema" AS ENUM('base', 'contrast');
  CREATE TYPE "public"."enum_design_default_font" AS ENUM('cairo', 'roboto', 'openSans', 'lato', 'nunito', 'raleway', 'faustina', 'merriweather', 'sourceSans3', 'playfairDisplay', 'lora', 'crimsonText', 'ebGaramond');
  CREATE TYPE "public"."enum_design_header_font" AS ENUM('cairo', 'roboto', 'openSans', 'lato', 'nunito', 'raleway', 'faustina', 'merriweather', 'sourceSans3', 'playfairDisplay', 'lora', 'crimsonText', 'ebGaramond');
  CREATE TABLE "pages_blocks_page_header" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar NOT NULL,
  	"description" varchar NOT NULL,
  	"image_id" uuid,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_text" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"content" jsonb NOT NULL,
  	"width" "enum_pages_blocks_text_width" DEFAULT '1/2' NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_title" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar NOT NULL,
  	"subtitle" varchar,
  	"size" "enum_pages_blocks_title_size" DEFAULT 'lg',
  	"align" "enum_pages_blocks_title_align" DEFAULT 'left',
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_section" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"background_color" "enum_pages_blocks_section_background_color" DEFAULT 'none',
  	"padding" "enum_pages_blocks_section_padding" DEFAULT 'large',
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_gallery_items" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"photo_id" uuid NOT NULL
  );
  
  CREATE TABLE "pages_blocks_gallery" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_document" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"file_id" uuid NOT NULL,
  	"button" varchar DEFAULT 'Download Flyer' NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_youtube" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"youtube_id" varchar NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_button" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"text" varchar NOT NULL,
  	"url" varchar NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_contactform" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar DEFAULT 'Ich bin dabei!' NOT NULL,
  	"description" varchar DEFAULT 'Um dich anzumelden oder uns zu unterstützen, fülle bitte das Kontaktformular aus. Wir freuen uns sehr, dass du Teil unserer Gemeinschaft bist und mit deinem Engagement dazu beiträgst, unsere Ziele zu erreichen. Solltest du Fragen haben oder weitere Informationen benötigen, zögere nicht, uns zu kontaktieren – wir sind gerne für dich da!' NOT NULL,
  	"email" varchar NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_donation" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_banner" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"text_line1" varchar,
  	"text_line2" varchar,
  	"text_line3" varchar,
  	"background_color" varchar,
  	"background_image_id" uuid,
  	"background_position" "enum_pages_blocks_banner_background_position" DEFAULT 'center center',
  	"background_size" "enum_pages_blocks_banner_background_size" DEFAULT 'cover',
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_main_text" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"text" varchar DEFAULT 'Jesus sagte zu ihm: Ich bin der Weg und die Wahrheit und das Leben; niemand kommt zum Vater außer durch mich. Wenn ihr mich erkannt habt, werdet ihr auch meinen Vater erkennen.' NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_horizontal_rule" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"color" "enum_pages_blocks_horizontal_rule_color" DEFAULT 'base' NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_blog_slider" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar DEFAULT 'Aktuelles',
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_mass_times" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar DEFAULT 'Nächste Gottesdienste',
  	"subtitle" varchar,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_collapsible_image_with_text" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar NOT NULL,
  	"text" varchar NOT NULL,
  	"image_id" uuid NOT NULL,
  	"content" jsonb NOT NULL,
  	"background_color" "enum_pages_blocks_collapsible_image_with_text_background_color" DEFAULT 'none',
  	"schema" "enum_pages_blocks_collapsible_image_with_text_schema" DEFAULT 'base',
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_events" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar DEFAULT 'Veranstaltungen',
  	"items_per_page" numeric DEFAULT 6,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages_blocks_publication_and_newsletter" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"_path" text NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"block_name" varchar
  );
  
  CREATE TABLE "pages" (
  	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
  	"title" varchar NOT NULL,
  	"description" varchar,
  	"slug" varchar NOT NULL,
  	"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
  	"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
  );
  
  CREATE TABLE "prayers" (
  	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
  	"text" varchar NOT NULL,
  	"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
  	"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
  );
  
  CREATE TABLE "footer_groups_links" (
  	"_order" integer NOT NULL,
  	"_parent_id" varchar NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"label" varchar NOT NULL,
  	"href" varchar NOT NULL
  );
  
  CREATE TABLE "footer_groups" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"title" varchar NOT NULL
  );
  
  CREATE TABLE "footer" (
  	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
  	"updated_at" timestamp(3) with time zone,
  	"created_at" timestamp(3) with time zone
  );
  
  CREATE TABLE "design" (
  	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
  	"base_color" varchar DEFAULT '#016699',
  	"shade1" varchar DEFAULT '#67A3C2',
  	"shade2" varchar DEFAULT '#DDECF7',
  	"shade3" varchar DEFAULT '#eff6ff',
  	"contrast_color" varchar DEFAULT '#CE490F',
  	"contrast_shade1" varchar DEFAULT '#DA764B',
  	"default_font" "enum_design_default_font" DEFAULT 'cairo',
  	"header_font" "enum_design_header_font" DEFAULT 'faustina',
  	"border_radius" varchar DEFAULT '13px',
  	"updated_at" timestamp(3) with time zone,
  	"created_at" timestamp(3) with time zone
  );
  
  CREATE TABLE "site_config_keywords" (
  	"_order" integer NOT NULL,
  	"_parent_id" uuid NOT NULL,
  	"id" varchar PRIMARY KEY NOT NULL,
  	"keyword" varchar NOT NULL
  );
  
  CREATE TABLE "site_config" (
  	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
  	"name" varchar DEFAULT 'Katholische Pfarrei Heilige Drei Könige Berlin' NOT NULL,
  	"short_name" varchar DEFAULT 'Heilige Drei Könige' NOT NULL,
  	"description" varchar DEFAULT 'Katholische Pfarrei Heilige Drei Könige in Berlin – Gottesdienste, Veranstaltungen, Sakramente und Gemeindeleben.' NOT NULL,
  	"url" varchar DEFAULT 'https://dreikoenige.berlin' NOT NULL,
  	"og_image" varchar DEFAULT '/og-logo.svg',
  	"email" varchar DEFAULT 'kontakt@dreikoenige.berlin' NOT NULL,
  	"updated_at" timestamp(3) with time zone,
  	"created_at" timestamp(3) with time zone
  );
  
  ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-03-15T11:16:16.612Z';
  ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-03-15T11:16:16.901Z';
  ALTER TABLE "blog_blocks_contactform" ALTER COLUMN "email" DROP DEFAULT;
  ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-04-08T10:16:16.962Z';
  ALTER TABLE "group_blocks_contactform" ALTER COLUMN "email" DROP DEFAULT;
  ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "pages_id" uuid;
  ALTER TABLE "payload_locked_documents_rels" ADD COLUMN "prayers_id" uuid;
  ALTER TABLE "pages_blocks_page_header" ADD CONSTRAINT "pages_blocks_page_header_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "pages_blocks_page_header" ADD CONSTRAINT "pages_blocks_page_header_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_text" ADD CONSTRAINT "pages_blocks_text_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_title" ADD CONSTRAINT "pages_blocks_title_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_section" ADD CONSTRAINT "pages_blocks_section_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_gallery_items" ADD CONSTRAINT "pages_blocks_gallery_items_photo_id_media_id_fk" FOREIGN KEY ("photo_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "pages_blocks_gallery_items" ADD CONSTRAINT "pages_blocks_gallery_items_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages_blocks_gallery"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_gallery" ADD CONSTRAINT "pages_blocks_gallery_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_document" ADD CONSTRAINT "pages_blocks_document_file_id_documents_id_fk" FOREIGN KEY ("file_id") REFERENCES "public"."documents"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "pages_blocks_document" ADD CONSTRAINT "pages_blocks_document_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_youtube" ADD CONSTRAINT "pages_blocks_youtube_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_button" ADD CONSTRAINT "pages_blocks_button_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_contactform" ADD CONSTRAINT "pages_blocks_contactform_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_donation" ADD CONSTRAINT "pages_blocks_donation_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_banner" ADD CONSTRAINT "pages_blocks_banner_background_image_id_media_id_fk" FOREIGN KEY ("background_image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "pages_blocks_banner" ADD CONSTRAINT "pages_blocks_banner_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_main_text" ADD CONSTRAINT "pages_blocks_main_text_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_horizontal_rule" ADD CONSTRAINT "pages_blocks_horizontal_rule_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_blog_slider" ADD CONSTRAINT "pages_blocks_blog_slider_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_mass_times" ADD CONSTRAINT "pages_blocks_mass_times_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_collapsible_image_with_text" ADD CONSTRAINT "pages_blocks_collapsible_image_with_text_image_id_media_id_fk" FOREIGN KEY ("image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
  ALTER TABLE "pages_blocks_collapsible_image_with_text" ADD CONSTRAINT "pages_blocks_collapsible_image_with_text_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_events" ADD CONSTRAINT "pages_blocks_events_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "pages_blocks_publication_and_newsletter" ADD CONSTRAINT "pages_blocks_publication_and_newsletter_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "footer_groups_links" ADD CONSTRAINT "footer_groups_links_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."footer_groups"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "footer_groups" ADD CONSTRAINT "footer_groups_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."footer"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "site_config_keywords" ADD CONSTRAINT "site_config_keywords_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."site_config"("id") ON DELETE cascade ON UPDATE no action;
  CREATE INDEX "pages_blocks_page_header_order_idx" ON "pages_blocks_page_header" USING btree ("_order");
  CREATE INDEX "pages_blocks_page_header_parent_id_idx" ON "pages_blocks_page_header" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_page_header_path_idx" ON "pages_blocks_page_header" USING btree ("_path");
  CREATE INDEX "pages_blocks_page_header_image_idx" ON "pages_blocks_page_header" USING btree ("image_id");
  CREATE INDEX "pages_blocks_text_order_idx" ON "pages_blocks_text" USING btree ("_order");
  CREATE INDEX "pages_blocks_text_parent_id_idx" ON "pages_blocks_text" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_text_path_idx" ON "pages_blocks_text" USING btree ("_path");
  CREATE INDEX "pages_blocks_title_order_idx" ON "pages_blocks_title" USING btree ("_order");
  CREATE INDEX "pages_blocks_title_parent_id_idx" ON "pages_blocks_title" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_title_path_idx" ON "pages_blocks_title" USING btree ("_path");
  CREATE INDEX "pages_blocks_section_order_idx" ON "pages_blocks_section" USING btree ("_order");
  CREATE INDEX "pages_blocks_section_parent_id_idx" ON "pages_blocks_section" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_section_path_idx" ON "pages_blocks_section" USING btree ("_path");
  CREATE INDEX "pages_blocks_gallery_items_order_idx" ON "pages_blocks_gallery_items" USING btree ("_order");
  CREATE INDEX "pages_blocks_gallery_items_parent_id_idx" ON "pages_blocks_gallery_items" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_gallery_items_photo_idx" ON "pages_blocks_gallery_items" USING btree ("photo_id");
  CREATE INDEX "pages_blocks_gallery_order_idx" ON "pages_blocks_gallery" USING btree ("_order");
  CREATE INDEX "pages_blocks_gallery_parent_id_idx" ON "pages_blocks_gallery" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_gallery_path_idx" ON "pages_blocks_gallery" USING btree ("_path");
  CREATE INDEX "pages_blocks_document_order_idx" ON "pages_blocks_document" USING btree ("_order");
  CREATE INDEX "pages_blocks_document_parent_id_idx" ON "pages_blocks_document" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_document_path_idx" ON "pages_blocks_document" USING btree ("_path");
  CREATE INDEX "pages_blocks_document_file_idx" ON "pages_blocks_document" USING btree ("file_id");
  CREATE INDEX "pages_blocks_youtube_order_idx" ON "pages_blocks_youtube" USING btree ("_order");
  CREATE INDEX "pages_blocks_youtube_parent_id_idx" ON "pages_blocks_youtube" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_youtube_path_idx" ON "pages_blocks_youtube" USING btree ("_path");
  CREATE INDEX "pages_blocks_button_order_idx" ON "pages_blocks_button" USING btree ("_order");
  CREATE INDEX "pages_blocks_button_parent_id_idx" ON "pages_blocks_button" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_button_path_idx" ON "pages_blocks_button" USING btree ("_path");
  CREATE INDEX "pages_blocks_contactform_order_idx" ON "pages_blocks_contactform" USING btree ("_order");
  CREATE INDEX "pages_blocks_contactform_parent_id_idx" ON "pages_blocks_contactform" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_contactform_path_idx" ON "pages_blocks_contactform" USING btree ("_path");
  CREATE INDEX "pages_blocks_donation_order_idx" ON "pages_blocks_donation" USING btree ("_order");
  CREATE INDEX "pages_blocks_donation_parent_id_idx" ON "pages_blocks_donation" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_donation_path_idx" ON "pages_blocks_donation" USING btree ("_path");
  CREATE INDEX "pages_blocks_banner_order_idx" ON "pages_blocks_banner" USING btree ("_order");
  CREATE INDEX "pages_blocks_banner_parent_id_idx" ON "pages_blocks_banner" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_banner_path_idx" ON "pages_blocks_banner" USING btree ("_path");
  CREATE INDEX "pages_blocks_banner_background_image_idx" ON "pages_blocks_banner" USING btree ("background_image_id");
  CREATE INDEX "pages_blocks_main_text_order_idx" ON "pages_blocks_main_text" USING btree ("_order");
  CREATE INDEX "pages_blocks_main_text_parent_id_idx" ON "pages_blocks_main_text" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_main_text_path_idx" ON "pages_blocks_main_text" USING btree ("_path");
  CREATE INDEX "pages_blocks_horizontal_rule_order_idx" ON "pages_blocks_horizontal_rule" USING btree ("_order");
  CREATE INDEX "pages_blocks_horizontal_rule_parent_id_idx" ON "pages_blocks_horizontal_rule" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_horizontal_rule_path_idx" ON "pages_blocks_horizontal_rule" USING btree ("_path");
  CREATE INDEX "pages_blocks_blog_slider_order_idx" ON "pages_blocks_blog_slider" USING btree ("_order");
  CREATE INDEX "pages_blocks_blog_slider_parent_id_idx" ON "pages_blocks_blog_slider" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_blog_slider_path_idx" ON "pages_blocks_blog_slider" USING btree ("_path");
  CREATE INDEX "pages_blocks_mass_times_order_idx" ON "pages_blocks_mass_times" USING btree ("_order");
  CREATE INDEX "pages_blocks_mass_times_parent_id_idx" ON "pages_blocks_mass_times" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_mass_times_path_idx" ON "pages_blocks_mass_times" USING btree ("_path");
  CREATE INDEX "pages_blocks_collapsible_image_with_text_order_idx" ON "pages_blocks_collapsible_image_with_text" USING btree ("_order");
  CREATE INDEX "pages_blocks_collapsible_image_with_text_parent_id_idx" ON "pages_blocks_collapsible_image_with_text" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_collapsible_image_with_text_path_idx" ON "pages_blocks_collapsible_image_with_text" USING btree ("_path");
  CREATE INDEX "pages_blocks_collapsible_image_with_text_image_idx" ON "pages_blocks_collapsible_image_with_text" USING btree ("image_id");
  CREATE INDEX "pages_blocks_events_order_idx" ON "pages_blocks_events" USING btree ("_order");
  CREATE INDEX "pages_blocks_events_parent_id_idx" ON "pages_blocks_events" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_events_path_idx" ON "pages_blocks_events" USING btree ("_path");
  CREATE INDEX "pages_blocks_publication_and_newsletter_order_idx" ON "pages_blocks_publication_and_newsletter" USING btree ("_order");
  CREATE INDEX "pages_blocks_publication_and_newsletter_parent_id_idx" ON "pages_blocks_publication_and_newsletter" USING btree ("_parent_id");
  CREATE INDEX "pages_blocks_publication_and_newsletter_path_idx" ON "pages_blocks_publication_and_newsletter" USING btree ("_path");
  CREATE UNIQUE INDEX "pages_slug_idx" ON "pages" USING btree ("slug");
  CREATE INDEX "pages_updated_at_idx" ON "pages" USING btree ("updated_at");
  CREATE INDEX "pages_created_at_idx" ON "pages" USING btree ("created_at");
  CREATE INDEX "prayers_updated_at_idx" ON "prayers" USING btree ("updated_at");
  CREATE INDEX "prayers_created_at_idx" ON "prayers" USING btree ("created_at");
  CREATE INDEX "footer_groups_links_order_idx" ON "footer_groups_links" USING btree ("_order");
  CREATE INDEX "footer_groups_links_parent_id_idx" ON "footer_groups_links" USING btree ("_parent_id");
  CREATE INDEX "footer_groups_order_idx" ON "footer_groups" USING btree ("_order");
  CREATE INDEX "footer_groups_parent_id_idx" ON "footer_groups" USING btree ("_parent_id");
  CREATE INDEX "site_config_keywords_order_idx" ON "site_config_keywords" USING btree ("_order");
  CREATE INDEX "site_config_keywords_parent_id_idx" ON "site_config_keywords" USING btree ("_parent_id");
  ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_pages_fk" FOREIGN KEY ("pages_id") REFERENCES "public"."pages"("id") ON DELETE cascade ON UPDATE no action;
  ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_prayers_fk" FOREIGN KEY ("prayers_id") REFERENCES "public"."prayers"("id") ON DELETE cascade ON UPDATE no action;
  CREATE INDEX "payload_locked_documents_rels_pages_id_idx" ON "payload_locked_documents_rels" USING btree ("pages_id");
  CREATE INDEX "payload_locked_documents_rels_prayers_id_idx" ON "payload_locked_documents_rels" USING btree ("prayers_id");
  ALTER TABLE "parish_blocks_text" DROP COLUMN "content_html";
  ALTER TABLE "blog_blocks_text" DROP COLUMN "content_html";
  ALTER TABLE "group_blocks_text" DROP COLUMN "content_html";
  ALTER TABLE "group" DROP COLUMN "text_html";
  INSERT INTO prayers (text) VALUES
      ('Herr, erbarme Dich meiner.'),
      ('Herr Jesus Christus, erbarme dich meiner.'),
      ('Ehre sei dem Vater, und dem Sohn und dem Heiligen Geist.'),
      ('Preiset den Herrn zu aller Zeit, denn er ist gut.'),
      ('Mein Herr und mein Gott.'),
      ('Herr, dir in die Hände sei Anfang und Ende, sei alles gelegt.'),
      ('Herr, du weißt alles; du weißt, dass ich dich liebe.'),
      ('Der Herr ist mein Licht und mein Heil, vor wem sollte ich mich fürchten?'),
      ('Herr, dein Wille geschehe.'),
      ('Ich glaube, Herr; hilf meinem Unglauben.'),
      ('O Gott, komm mir zu Hilfe. Herr, eile, mir zu helfen.'),
      ('Jesus, ich vertraue auf Dich.'),
      ('Gegrüßet seist du, Maria, voll der Gnade, der Herr ist mit dir.'),
      ('Gelobt sei Jesus Christus - in Ewigkeit. Amen.'),
      ('Maria mit dem Kinde lieb, uns allen deinen Segen gib.'),
      ('Aus der Tiefe rufe ich Herr zu dir. Herr, höre meine Stimme.'),
      ('Durch sein schmerzhaftes Leiden, habe Erbarmen mit uns und mit der ganzen Welt.'),
      ('Heiliger Gott, habe Erbarmen mit uns und mit der ganzen Welt.'),
      ('Heilige Maria, Mutter Gottes, bitte für uns Sünder.'),
      ('Gepriesen seist du, Herr. Lehre mich deine Gesetze.');
`)
}

export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
  await db.execute(sql`
   ALTER TABLE "pages_blocks_page_header" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_text" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_title" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_section" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_gallery_items" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_gallery" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_document" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_youtube" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_button" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_contactform" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_donation" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_banner" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_main_text" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_horizontal_rule" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_blog_slider" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_mass_times" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_collapsible_image_with_text" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_events" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages_blocks_publication_and_newsletter" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "pages" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "prayers" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "footer_groups_links" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "footer_groups" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "footer" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "design" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "site_config_keywords" DISABLE ROW LEVEL SECURITY;
  ALTER TABLE "site_config" DISABLE ROW LEVEL SECURITY;
  DROP TABLE "pages_blocks_page_header" CASCADE;
  DROP TABLE "pages_blocks_text" CASCADE;
  DROP TABLE "pages_blocks_title" CASCADE;
  DROP TABLE "pages_blocks_section" CASCADE;
  DROP TABLE "pages_blocks_gallery_items" CASCADE;
  DROP TABLE "pages_blocks_gallery" CASCADE;
  DROP TABLE "pages_blocks_document" CASCADE;
  DROP TABLE "pages_blocks_youtube" CASCADE;
  DROP TABLE "pages_blocks_button" CASCADE;
  DROP TABLE "pages_blocks_contactform" CASCADE;
  DROP TABLE "pages_blocks_donation" CASCADE;
  DROP TABLE "pages_blocks_banner" CASCADE;
  DROP TABLE "pages_blocks_main_text" CASCADE;
  DROP TABLE "pages_blocks_horizontal_rule" CASCADE;
  DROP TABLE "pages_blocks_blog_slider" CASCADE;
  DROP TABLE "pages_blocks_mass_times" CASCADE;
  DROP TABLE "pages_blocks_collapsible_image_with_text" CASCADE;
  DROP TABLE "pages_blocks_events" CASCADE;
  DROP TABLE "pages_blocks_publication_and_newsletter" CASCADE;
  DROP TABLE "pages" CASCADE;
  DROP TABLE "prayers" CASCADE;
  DROP TABLE "footer_groups_links" CASCADE;
  DROP TABLE "footer_groups" CASCADE;
  DROP TABLE "footer" CASCADE;
  DROP TABLE "design" CASCADE;
  DROP TABLE "site_config_keywords" CASCADE;
  DROP TABLE "site_config" CASCADE;
  ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_pages_fk";
  
  ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT "payload_locked_documents_rels_prayers_fk";
  
  DROP INDEX "payload_locked_documents_rels_pages_id_idx";
  DROP INDEX "payload_locked_documents_rels_prayers_id_idx";
  ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-02-08T15:57:34.492Z';
  ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-02-08T15:57:34.801Z';
  ALTER TABLE "blog_blocks_contactform" ALTER COLUMN "email" SET DEFAULT 'kontakt@dreikoenige.berlin';
  ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-03-07T15:57:34.871Z';
  ALTER TABLE "group_blocks_contactform" ALTER COLUMN "email" SET DEFAULT 'kontakt@dreikoenige.berlin';
  ALTER TABLE "parish_blocks_text" ADD COLUMN "content_html" varchar;
  ALTER TABLE "blog_blocks_text" ADD COLUMN "content_html" varchar;
  ALTER TABLE "group_blocks_text" ADD COLUMN "content_html" varchar;
  ALTER TABLE "group" ADD COLUMN "text_html" varchar;
  ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "pages_id";
  ALTER TABLE "payload_locked_documents_rels" DROP COLUMN "prayers_id";
  DROP TYPE "public"."enum_pages_blocks_text_width";
  DROP TYPE "public"."enum_pages_blocks_title_size";
  DROP TYPE "public"."enum_pages_blocks_title_align";
  DROP TYPE "public"."enum_pages_blocks_section_background_color";
  DROP TYPE "public"."enum_pages_blocks_section_padding";
  DROP TYPE "public"."enum_pages_blocks_banner_background_position";
  DROP TYPE "public"."enum_pages_blocks_banner_background_size";
  DROP TYPE "public"."enum_pages_blocks_horizontal_rule_color";
  DROP TYPE "public"."enum_pages_blocks_collapsible_image_with_text_background_color";
  DROP TYPE "public"."enum_pages_blocks_collapsible_image_with_text_schema";
  DROP TYPE "public"."enum_design_default_font";
  DROP TYPE "public"."enum_design_header_font";`)
}
