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

export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
  await db.execute(sql`
   ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-06-14T11:32:58.445Z';
  ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-06-14T11:32:58.773Z';
  ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-07-09T11:32:58.852Z';
  ALTER TABLE "parish_gallery" ADD COLUMN "caption" varchar;
  ALTER TABLE "_parish_v_version_gallery" ADD COLUMN "caption" varchar;`)
}

export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
  await db.execute(sql`
   ALTER TABLE "announcement" ALTER COLUMN "date" SET DEFAULT '2026-06-07T13:08:42.418Z';
  ALTER TABLE "calendar" ALTER COLUMN "date" SET DEFAULT '2026-06-07T13:08:42.705Z';
  ALTER TABLE "classifieds" ALTER COLUMN "until" SET DEFAULT '2026-07-05T13:08:42.759Z';
  ALTER TABLE "parish_gallery" DROP COLUMN "caption";
  ALTER TABLE "_parish_v_version_gallery" DROP COLUMN "caption";`)
}
