fix: manual migration for Agbs collection to resolve staging 500 error and cleanup failures
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 1m17s
Build & Deploy / 🏗️ Build (push) Successful in 3m46s
Build & Deploy / 🚀 Deploy (push) Successful in 15s
Build & Deploy / 🧪 Post-Deploy Verification (push) Failing after 5m8s
Build & Deploy / 🔔 Notify (push) Successful in 3s

This commit is contained in:
2026-04-27 14:14:43 +02:00
parent de0089f068
commit ce6436ab0a
4 changed files with 65 additions and 6 deletions

View File

@@ -116,6 +116,7 @@
"pdf:datasheets": "tsx ./scripts/generate-pdf-datasheets.ts",
"pdf:datasheets:legacy": "tsx ./scripts/generate-pdf-datasheets-pdf-lib.ts",
"cms:migrate": "payload migrate",
"cms:migrate:create": "payload migrate:create",
"cms:seed": "tsx ./scripts/seed-payload.ts",
"assets:push:testing": "bash ./scripts/assets-sync.sh local testing",
"assets:push:staging": "bash ./scripts/assets-sync.sh local staging",
@@ -139,7 +140,7 @@
"prepare": "husky",
"preinstall": "npx only-allow pnpm"
},
"version": "2.3.22-rc.3",
"version": "2.3.22-rc.4",
"pnpm": {
"onlyBuiltDependencies": [
"@parcel/watcher",

View File

@@ -1,5 +0,0 @@
{
"id": "20260225_003500_add_pages_collection",
"name": "20260225_003500_add_pages_collection",
"batch": 3
}

View File

@@ -0,0 +1,56 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres';
export async function up({ db }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
CREATE TABLE IF NOT EXISTS "agbs_collection" (
"id" serial PRIMARY KEY NOT NULL,
"version_date" timestamp(3) with time zone NOT NULL,
"file_id" integer NOT NULL,
"is_current" boolean DEFAULT false,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE IF NOT EXISTS "agbs_collection_locales" (
"id" serial PRIMARY KEY NOT NULL,
"title" varchar,
"_locale" "enum__locales" NOT NULL,
"_parent_id" integer NOT NULL
);
DO $$ BEGIN
ALTER TABLE "agbs_collection_locales" ADD CONSTRAINT "agbs_collection_locales_locale_parent_id_unique" UNIQUE("_locale", "_parent_id");
EXCEPTION WHEN duplicate_object THEN null; END $$;
DO $$ BEGIN
ALTER TABLE "agbs_collection_locales" ADD CONSTRAINT "agbs_collection_locales_parent_id_fk"
FOREIGN KEY ("_parent_id") REFERENCES "agbs_collection"("id") ON DELETE cascade;
EXCEPTION WHEN duplicate_object THEN null; END $$;
DO $$ BEGIN
ALTER TABLE "agbs_collection" ADD CONSTRAINT "agbs_collection_file_id_media_id_fk"
FOREIGN KEY ("file_id") REFERENCES "public"."media"("id") ON DELETE set null;
EXCEPTION WHEN duplicate_object THEN null; END $$;
CREATE INDEX IF NOT EXISTS "agbs_collection_updated_at_idx" ON "agbs_collection" USING btree ("updated_at");
CREATE INDEX IF NOT EXISTS "agbs_collection_created_at_idx" ON "agbs_collection" USING btree ("created_at");
-- Add to payload_locked_documents_rels
ALTER TABLE "payload_locked_documents_rels" ADD COLUMN IF NOT EXISTS "agbs_collection_id" integer;
DO $$ BEGIN
ALTER TABLE "payload_locked_documents_rels" ADD CONSTRAINT "payload_locked_documents_rels_agbs_collection_fk"
FOREIGN KEY ("agbs_collection_id") REFERENCES "public"."agbs_collection"("id") ON DELETE cascade;
EXCEPTION WHEN duplicate_object THEN null; END $$;
CREATE INDEX IF NOT EXISTS "payload_locked_documents_rels_agbs_collection_id_idx"
ON "payload_locked_documents_rels" USING btree ("agbs_collection_id");
`);
}
export async function down({ db }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "payload_locked_documents_rels" DROP CONSTRAINT IF EXISTS "payload_locked_documents_rels_agbs_collection_fk";
ALTER TABLE "payload_locked_documents_rels" DROP COLUMN IF EXISTS "agbs_collection_id";
DROP TABLE IF EXISTS "agbs_collection_locales" CASCADE;
DROP TABLE IF EXISTS "agbs_collection" CASCADE;
`);
}

View File

@@ -5,6 +5,8 @@ import * as migration_20260225_175000_native_localization from './20260225_17500
import * as migration_20260305_215000_products_featured_image from './20260305_215000_products_featured_image';
import * as migration_20260312_120000_pages_redirect_fields from './20260312_120000_pages_redirect_fields';
import * as migration_20260427_123000_add_agbs_collection from './20260427_123000_add_agbs_collection';
export const migrations = [
{
up: migration_20260223_195005_products_collection.up,
@@ -36,4 +38,9 @@ export const migrations = [
down: migration_20260312_120000_pages_redirect_fields.down,
name: '20260312_120000_pages_redirect_fields',
},
{
up: migration_20260427_123000_add_agbs_collection.up,
down: migration_20260427_123000_add_agbs_collection.down,
name: '20260427_123000_add_agbs_collection',
},
];