mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
cb003116a5
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.
12 lines
469 B
SQL
12 lines
469 B
SQL
-- 0030_drop_tts_model_unique
|
|
-- Drop unique constraint on (tts_provider_id, model_id) to allow multiple
|
|
-- models with the same model_id under one provider (different configs).
|
|
-- NOTE: No-op on fresh databases where tts_models no longer exists.
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'tts_models') THEN
|
|
EXECUTE 'ALTER TABLE tts_models DROP CONSTRAINT IF EXISTS tts_models_provider_model_id_unique';
|
|
END IF;
|
|
END $$;
|