church-website/src/migrations/20260310_105814.ts
2026-03-10 14:42:01 +01:00

66 lines
3.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
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 "design" CASCADE;
DROP TABLE "site_config_keywords" CASCADE;
DROP TABLE "site_config" CASCADE;
ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-03-15T10:58:14.115Z';
ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-03-15T10:58:14.432Z';
ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-04-09T09:58:14.493Z';
ALTER TABLE "documents" DROP COLUMN "prefix";
ALTER TABLE "media" DROP COLUMN "prefix";
DROP TYPE "public"."enum_design_default_font";
DROP TYPE "public"."enum_design_header_font";`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
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 "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 'Hl. 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 "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-04-08T10:16:16.962Z';
ALTER TABLE "documents" ADD COLUMN "prefix" varchar DEFAULT 'documents/';
ALTER TABLE "media" ADD COLUMN "prefix" varchar DEFAULT 'media/';
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 "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");`)
}