feat(cms): add form relationship field to GroupVisitsPage and BirthdayPage
This commit is contained in:
parent
5e998daa8d
commit
ff4ae6934c
5 changed files with 64 additions and 0 deletions
5
migrations/20260518_115657.json
Normal file
5
migrations/20260518_115657.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {}
|
||||
}
|
||||
33
migrations/20260518_115657.ts
Normal file
33
migrations/20260518_115657.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||
|
||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
ALTER TABLE "group_visits_page" ADD COLUMN "form_id" integer;
|
||||
ALTER TABLE "group_visits_page" ADD CONSTRAINT "group_visits_page_form_id_forms_id_fk" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE "_group_visits_page_v" ADD COLUMN "form_id" integer;
|
||||
ALTER TABLE "_group_visits_page_v" ADD CONSTRAINT "_group_visits_page_v_form_id_forms_id_fk" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE "birthday_page" ADD COLUMN "form_id" integer;
|
||||
ALTER TABLE "birthday_page" ADD CONSTRAINT "birthday_page_form_id_forms_id_fk" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE "_birthday_page_v" ADD COLUMN "form_id" integer;
|
||||
ALTER TABLE "_birthday_page_v" ADD CONSTRAINT "_birthday_page_v_form_id_forms_id_fk" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE SET NULL;
|
||||
`)
|
||||
}
|
||||
|
||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
ALTER TABLE "group_visits_page" DROP CONSTRAINT IF EXISTS "group_visits_page_form_id_forms_id_fk";
|
||||
ALTER TABLE "group_visits_page" DROP COLUMN IF EXISTS "form_id";
|
||||
|
||||
ALTER TABLE "_group_visits_page_v" DROP CONSTRAINT IF EXISTS "_group_visits_page_v_form_id_forms_id_fk";
|
||||
ALTER TABLE "_group_visits_page_v" DROP COLUMN IF EXISTS "form_id";
|
||||
|
||||
ALTER TABLE "birthday_page" DROP CONSTRAINT IF EXISTS "birthday_page_form_id_forms_id_fk";
|
||||
ALTER TABLE "birthday_page" DROP COLUMN IF EXISTS "form_id";
|
||||
|
||||
ALTER TABLE "_birthday_page_v" DROP CONSTRAINT IF EXISTS "_birthday_page_v_form_id_forms_id_fk";
|
||||
ALTER TABLE "_birthday_page_v" DROP COLUMN IF EXISTS "form_id";
|
||||
`)
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import * as migration_20260515_153940 from './20260515_153940'
|
||||
import * as migration_20260515_162527 from './20260515_162527'
|
||||
import * as migration_20260518_104929 from './20260518_104929'
|
||||
import * as migration_20260518_115657 from './20260518_115657'
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
|
|
@ -18,4 +19,9 @@ export const migrations = [
|
|||
down: migration_20260518_104929.down,
|
||||
name: '20260518_104929',
|
||||
},
|
||||
{
|
||||
up: migration_20260518_115657.up,
|
||||
down: migration_20260518_115657.down,
|
||||
name: '20260518_115657',
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -31,5 +31,15 @@ export const BirthdayPage: GlobalConfig = {
|
|||
type: 'text',
|
||||
defaultValue: "Залиште заявку і наш менеджер зв'яжеться з вами протягом 30 хвилин",
|
||||
},
|
||||
{
|
||||
name: 'form',
|
||||
type: 'relationship',
|
||||
relationTo: 'forms',
|
||||
label: 'Форма замовлення',
|
||||
admin: {
|
||||
description:
|
||||
'CMS-форма для відображення на сторінці. Якщо не вказано — використовується вбудована форма.',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,5 +73,15 @@ export const GroupVisitsPage: GlobalConfig = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'form',
|
||||
type: 'relationship',
|
||||
relationTo: 'forms',
|
||||
label: 'Форма заявки',
|
||||
admin: {
|
||||
description:
|
||||
'CMS-форма для відображення на сторінці. Якщо не вказано — використовується вбудована форма.',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue