Files
Memoh/db/migrations/0050_tts_provider_enable.up.sql
T
Acbox cb003116a5 fix: use EXECUTE for dynamic SQL in migrations referencing old schema
PL/pgSQL pre-validates column/table references in static SQL statements
inside DO blocks before evaluating IF/RETURN guards. This caused
migrations 0010-0061 to fail on fresh databases where the canonical
schema uses `providers`/`provider_id` instead of `llm_providers`/
`llm_provider_id`.

Wrap all SQL that references potentially non-existent old schema objects
(llm_providers, llm_provider_id, tts_providers, tts_models, etc.) in
EXECUTE strings so they are only parsed at runtime when actually reached.
2026-04-07 00:39:37 +08:00

11 lines
404 B
SQL

-- 0050_tts_provider_enable
-- Add enable column to tts_providers table for toggling providers on/off.
-- NOTE: No-op on fresh databases where tts_providers no longer exists.
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'tts_providers') THEN
EXECUTE 'ALTER TABLE tts_providers ADD COLUMN IF NOT EXISTS enable BOOLEAN NOT NULL DEFAULT false';
END IF;
END $$;