feat(db): add migration for pages redirect fields
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 54s
Build & Deploy / 🏗️ Build (push) Failing after 15s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Successful in 54s
Build & Deploy / 🏗️ Build (push) Failing after 15s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
22
src/migrations/20260312_120000_pages_redirect_fields.ts
Normal file
22
src/migrations/20260312_120000_pages_redirect_fields.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres';
|
||||||
|
|
||||||
|
export async function up({ db }: MigrateUpArgs): Promise<void> {
|
||||||
|
// redirect_permanent is a non-localized checkbox → stored on the main pages table
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "pages" ADD COLUMN IF NOT EXISTS "redirect_permanent" boolean DEFAULT true;
|
||||||
|
`);
|
||||||
|
|
||||||
|
// redirect_url is a localized text field → stored on the pages_locales table
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "pages_locales" ADD COLUMN IF NOT EXISTS "redirect_url" varchar;
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({ db }: MigrateDownArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "pages" DROP COLUMN IF EXISTS "redirect_permanent";
|
||||||
|
`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "pages_locales" DROP COLUMN IF EXISTS "redirect_url";
|
||||||
|
`);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import * as migration_20260223_195151_remove_sku_unique from './20260223_195151_
|
|||||||
import * as migration_20260225_003500_add_pages_collection from './20260225_003500_add_pages_collection';
|
import * as migration_20260225_003500_add_pages_collection from './20260225_003500_add_pages_collection';
|
||||||
import * as migration_20260225_175000_native_localization from './20260225_175000_native_localization';
|
import * as migration_20260225_175000_native_localization from './20260225_175000_native_localization';
|
||||||
import * as migration_20260305_215000_products_featured_image from './20260305_215000_products_featured_image';
|
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';
|
||||||
|
|
||||||
export const migrations = [
|
export const migrations = [
|
||||||
{
|
{
|
||||||
@@ -30,4 +31,9 @@ export const migrations = [
|
|||||||
down: migration_20260305_215000_products_featured_image.down,
|
down: migration_20260305_215000_products_featured_image.down,
|
||||||
name: '20260305_215000_products_featured_image',
|
name: '20260305_215000_products_featured_image',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
up: migration_20260312_120000_pages_redirect_fields.up,
|
||||||
|
down: migration_20260312_120000_pages_redirect_fields.down,
|
||||||
|
name: '20260312_120000_pages_redirect_fields',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user