fix(migration): complete 0012 — add version table columns for faq field
Some checks are pending
CI / Type Check (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Unit Tests (push) Waiting to run
Deploy / Build & Push Image (push) Waiting to run
Deploy / Deploy to VPS (push) Blocked by required conditions

Add missing version_faq_title column to _home_page_v and create
_home_page_v_version_faq_items table; Payload versions: {max:20}
requires both the main table and the versions table to be in sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-06-04 14:36:23 +01:00
parent b33ec01b16
commit 9ae5852f7b

View file

@ -1,4 +1,11 @@
-- Migration: add home_page_faq_items table for FAQ accordion on home page
-- Migration: add FAQ fields to home_page global
-- Scalar faq_title goes on the main table; faq_items is an array child table.
-- The versions table (_home_page_v) mirrors these fields with version_ prefix.
-- 1. Main table: scalar column for faq title
ALTER TABLE home_page ADD COLUMN IF NOT EXISTS faq_title character varying;
-- 2. Main table: array child table for faq items
-- IMPORTANT: id must be character varying (not serial) — Payload generates string IDs
CREATE TABLE IF NOT EXISTS home_page_faq_items (
_order integer NOT NULL,
@ -12,3 +19,18 @@ CREATE TABLE IF NOT EXISTS home_page_faq_items (
);
CREATE INDEX IF NOT EXISTS home_page_faq_items_order_idx ON home_page_faq_items (_order);
CREATE INDEX IF NOT EXISTS home_page_faq_items_parent_id_idx ON home_page_faq_items (_parent_id);
-- 3. Versions table: scalar column mirror
ALTER TABLE _home_page_v ADD COLUMN IF NOT EXISTS version_faq_title character varying;
-- 4. Versions table: array child table mirror (uses serial id, _uuid, no timestamps)
CREATE TABLE IF NOT EXISTS _home_page_v_version_faq_items (
_order integer NOT NULL,
_parent_id integer NOT NULL REFERENCES _home_page_v(id) ON DELETE CASCADE,
id serial PRIMARY KEY,
question character varying,
answer text,
_uuid character varying
);
CREATE INDEX IF NOT EXISTS _home_page_v_version_faq_items_order_idx ON _home_page_v_version_faq_items (_order);
CREATE INDEX IF NOT EXISTS _home_page_v_version_faq_items_parent_id_idx ON _home_page_v_version_faq_items (_parent_id);