Files
backend/database/migrations/045_portfolios_title_fa_en.sql
T

22 lines
605 B
SQL

-- Bilingual portfolio titles (legacy name / name_en)
ALTER TABLE portfolios
ADD COLUMN IF NOT EXISTS title_fa VARCHAR(255);
ALTER TABLE portfolios
ADD COLUMN IF NOT EXISTS title_en VARCHAR(255);
-- Existing rows: FA from title; EN from content.nameEn when present
UPDATE portfolios
SET title_fa = title
WHERE title_fa IS NULL;
UPDATE portfolios
SET title_en = NULLIF(BTRIM(content->>'nameEn'), '')
WHERE title_en IS NULL
AND content ? 'nameEn';
-- Keep title as the primary FA display title
UPDATE portfolios
SET title = COALESCE(NULLIF(BTRIM(title_fa), ''), title)
WHERE title_fa IS NOT NULL;