chore(migrations): add SQL migration 0021 – convert all textarea columns to jsonb for Lexical
Covers: group_visits_page, dinosaur_page, dyvolis_page, tickets_page, home_page, birthday_page, locations, legal_pages child tables and their _v version tables. All blocks are idempotent (check data_type IN varchar/text before altering). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2d6e5f2fe0
commit
5a3be7d0ee
1 changed files with 370 additions and 0 deletions
370
migrations/0021_all_textarea_to_richtext.sql
Normal file
370
migrations/0021_all_textarea_to_richtext.sql
Normal file
|
|
@ -0,0 +1,370 @@
|
|||
-- Migration: convert all remaining textarea/text fields to jsonb for Lexical rich-text editor
|
||||
|
||||
-- ── group_visits_page: price_description ─────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'group_visits_page' AND column_name = 'price_description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "group_visits_page" ALTER COLUMN "price_description" DROP DEFAULT;
|
||||
ALTER TABLE "group_visits_page" ALTER COLUMN "price_description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_group_visits_page_v' AND column_name = 'version_price_description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_group_visits_page_v" ALTER COLUMN "version_price_description" DROP DEFAULT;
|
||||
ALTER TABLE "_group_visits_page_v" ALTER COLUMN "version_price_description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── dinosaur_page: hero_description, activities_description ──────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dinosaur_page' AND column_name = 'hero_description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "dinosaur_page" ALTER COLUMN "hero_description" DROP DEFAULT;
|
||||
ALTER TABLE "dinosaur_page" ALTER COLUMN "hero_description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dinosaur_page' AND column_name = 'activities_description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "dinosaur_page" ALTER COLUMN "activities_description" DROP DEFAULT;
|
||||
ALTER TABLE "dinosaur_page" ALTER COLUMN "activities_description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── dyvolis_page: hero_description ───────────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dyvolis_page' AND column_name = 'hero_description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "dyvolis_page" ALTER COLUMN "hero_description" DROP DEFAULT;
|
||||
ALTER TABLE "dyvolis_page" ALTER COLUMN "hero_description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── tickets_page: benefits_footnote ──────────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'tickets_page' AND column_name = 'benefits_footnote'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "tickets_page" ALTER COLUMN "benefits_footnote" DROP DEFAULT;
|
||||
ALTER TABLE "tickets_page" ALTER COLUMN "benefits_footnote" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_tickets_page_v' AND column_name = 'version_benefits_footnote'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_tickets_page_v" ALTER COLUMN "version_benefits_footnote" DROP DEFAULT;
|
||||
ALTER TABLE "_tickets_page_v" ALTER COLUMN "version_benefits_footnote" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── home_page: hero_subtitle, birthday_intro_text, news_subtitle ─────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'home_page' AND column_name = 'hero_subtitle'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "home_page" ALTER COLUMN "hero_subtitle" DROP DEFAULT;
|
||||
ALTER TABLE "home_page" ALTER COLUMN "hero_subtitle" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'home_page' AND column_name = 'birthday_intro_text'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "home_page" ALTER COLUMN "birthday_intro_text" DROP DEFAULT;
|
||||
ALTER TABLE "home_page" ALTER COLUMN "birthday_intro_text" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'home_page' AND column_name = 'news_subtitle'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "home_page" ALTER COLUMN "news_subtitle" DROP DEFAULT;
|
||||
ALTER TABLE "home_page" ALTER COLUMN "news_subtitle" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_home_page_v' AND column_name = 'version_hero_subtitle'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_home_page_v" ALTER COLUMN "version_hero_subtitle" DROP DEFAULT;
|
||||
ALTER TABLE "_home_page_v" ALTER COLUMN "version_hero_subtitle" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_home_page_v' AND column_name = 'version_birthday_intro_text'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_home_page_v" ALTER COLUMN "version_birthday_intro_text" DROP DEFAULT;
|
||||
ALTER TABLE "_home_page_v" ALTER COLUMN "version_birthday_intro_text" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_home_page_v' AND column_name = 'version_news_subtitle'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_home_page_v" ALTER COLUMN "version_news_subtitle" DROP DEFAULT;
|
||||
ALTER TABLE "_home_page_v" ALTER COLUMN "version_news_subtitle" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── home_page_why_parents_items: description ──────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'home_page_why_parents_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "home_page_why_parents_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "home_page_why_parents_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_home_page_v_version_why_parents_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_home_page_v_version_why_parents_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "_home_page_v_version_why_parents_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── home_page_hero_slides: subtitle ──────────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'home_page_hero_slides' AND column_name = 'subtitle'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "home_page_hero_slides" ALTER COLUMN "subtitle" DROP DEFAULT;
|
||||
ALTER TABLE "home_page_hero_slides" ALTER COLUMN "subtitle" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── home_page_faq_items: answer ───────────────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'home_page_faq_items' AND column_name = 'answer'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "home_page_faq_items" ALTER COLUMN "answer" DROP DEFAULT;
|
||||
ALTER TABLE "home_page_faq_items" ALTER COLUMN "answer" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── dinosaur_page_activities: description ────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dinosaur_page_activities' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "dinosaur_page_activities" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "dinosaur_page_activities" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── dinosaur_page_why_visit_items: description ───────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dinosaur_page_why_visit_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "dinosaur_page_why_visit_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "dinosaur_page_why_visit_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── birthday_page_package_items: description ─────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'birthday_page_package_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "birthday_page_package_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "birthday_page_package_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_birthday_page_v_version_package_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_birthday_page_v_version_package_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "_birthday_page_v_version_package_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── birthday_page_why_items: description ─────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'birthday_page_why_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "birthday_page_why_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "birthday_page_why_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_birthday_page_v_version_why_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_birthday_page_v_version_why_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "_birthday_page_v_version_why_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── dyvolis_page_why_visit_items: description ────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dyvolis_page_why_visit_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "dyvolis_page_why_visit_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "dyvolis_page_why_visit_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── tickets_page_combo_cards: description ────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'tickets_page_combo_cards' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "tickets_page_combo_cards" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "tickets_page_combo_cards" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = '_tickets_page_v_version_combo_cards' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "_tickets_page_v_version_combo_cards" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "_tickets_page_v_version_combo_cards" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── locations: short_desc ────────────────────────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'locations' AND column_name = 'short_desc'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "locations" ALTER COLUMN "short_desc" DROP DEFAULT;
|
||||
ALTER TABLE "locations" ALTER COLUMN "short_desc" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── locations_why_visit_items: description ───────────────────────────────────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'locations_why_visit_items' AND column_name = 'description'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "locations_why_visit_items" ALTER COLUMN "description" DROP DEFAULT;
|
||||
ALTER TABLE "locations_why_visit_items" ALTER COLUMN "description" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- ── legal_pages: content fields (privacy, terms, offer, data_processing) ─────
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'legal_pages' AND column_name = 'privacy_content'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "privacy_content" DROP DEFAULT;
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "privacy_content" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'legal_pages' AND column_name = 'terms_content'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "terms_content" DROP DEFAULT;
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "terms_content" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'legal_pages' AND column_name = 'offer_content'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "offer_content" DROP DEFAULT;
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "offer_content" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'legal_pages' AND column_name = 'data_processing_content'
|
||||
AND data_type IN ('character varying', 'text')
|
||||
) THEN
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "data_processing_content" DROP DEFAULT;
|
||||
ALTER TABLE "legal_pages" ALTER COLUMN "data_processing_content" TYPE jsonb USING NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
Loading…
Add table
Reference in a new issue