mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
fix: revert canonical schema to use llm_providers for migration compatibility
The CI migrations workflow (up → down → up) failed because 0061 down renames `providers` back to `llm_providers`, but 0001 down only dropped `providers` — leaving `llm_providers` as a remnant. On the second migrate up, 0010 found the stale `llm_providers` and tried to reference `models.llm_provider_id` which no longer existed. Revert 0001 canonical schema to use original names (llm_providers, tts_providers, tts_models) so incremental migrations work naturally and 0061 handles the final rename. Remove EXECUTE wrappers and unnecessary guards from migrations that now always operate on llm_providers.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
-- 0013_model_id_unique_per_provider
|
||||
-- Change model_id uniqueness from global to per provider.
|
||||
-- NOTE: On fresh databases the canonical schema already has the correct constraint.
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
@@ -8,11 +7,9 @@ BEGIN
|
||||
ALTER TABLE models DROP CONSTRAINT models_model_id_unique;
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'models_provider_model_id_unique')
|
||||
AND NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'models_provider_id_model_id_unique') THEN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'models' AND column_name = 'llm_provider_id') THEN
|
||||
EXECUTE 'ALTER TABLE models ADD CONSTRAINT models_provider_model_id_unique UNIQUE (llm_provider_id, model_id)';
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'models_provider_model_id_unique') THEN
|
||||
ALTER TABLE models
|
||||
ADD CONSTRAINT models_provider_model_id_unique UNIQUE (llm_provider_id, model_id);
|
||||
END IF;
|
||||
END
|
||||
$$;
|
||||
|
||||
Reference in New Issue
Block a user