diff --git a/migrations/20260518_115657.json b/migrations/20260518_115657.json new file mode 100644 index 0000000..1c83e0c --- /dev/null +++ b/migrations/20260518_115657.json @@ -0,0 +1,5 @@ +{ + "version": "7", + "dialect": "postgresql", + "tables": {} +} diff --git a/migrations/20260518_115657.ts b/migrations/20260518_115657.ts new file mode 100644 index 0000000..3ce8657 --- /dev/null +++ b/migrations/20260518_115657.ts @@ -0,0 +1,33 @@ +import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres' + +export async function up({ db, payload, req }: MigrateUpArgs): Promise { + 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 { + 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"; + `) +} diff --git a/migrations/index.ts b/migrations/index.ts index 7ddfcc5..8dfc971 100644 --- a/migrations/index.ts +++ b/migrations/index.ts @@ -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', + }, ] diff --git a/src/globals/BirthdayPage.ts b/src/globals/BirthdayPage.ts index 0e09228..0aeb1b4 100644 --- a/src/globals/BirthdayPage.ts +++ b/src/globals/BirthdayPage.ts @@ -31,5 +31,15 @@ export const BirthdayPage: GlobalConfig = { type: 'text', defaultValue: "Залиште заявку і наш менеджер зв'яжеться з вами протягом 30 хвилин", }, + { + name: 'form', + type: 'relationship', + relationTo: 'forms', + label: 'Форма замовлення', + admin: { + description: + 'CMS-форма для відображення на сторінці. Якщо не вказано — використовується вбудована форма.', + }, + }, ], } diff --git a/src/globals/GroupVisitsPage.ts b/src/globals/GroupVisitsPage.ts index 7f41581..9bb39b1 100644 --- a/src/globals/GroupVisitsPage.ts +++ b/src/globals/GroupVisitsPage.ts @@ -73,5 +73,15 @@ export const GroupVisitsPage: GlobalConfig = { }, ], }, + { + name: 'form', + type: 'relationship', + relationTo: 'forms', + label: 'Форма заявки', + admin: { + description: + 'CMS-форма для відображення на сторінці. Якщо не вказано — використовується вбудована форма.', + }, + }, ], }