Fix media uploads without alt text
CI / test (push) Canceled after 0s
CI / build-image (push) Canceled after 0s
Release / promote-and-deploy (push) Canceled after 0s

This commit is contained in:
2026-09-18 01:47:59 +02:00
parent d7576cb925
commit 661b12bb7b
2 changed files with 21 additions and 0 deletions
@@ -0,0 +1,15 @@
import { MigrateDownArgs, MigrateUpArgs, sql } from "@payloadcms/db-postgres";
/** Allows image uploads without requiring accessibility metadata at upload time. */
export async function up({ db }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "media" ALTER COLUMN "alt" DROP NOT NULL;
`);
}
export async function down({ db }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
UPDATE "media" SET "alt" = '' WHERE "alt" IS NULL;
ALTER TABLE "media" ALTER COLUMN "alt" SET NOT NULL;
`);
}