From c0c8603d053092be75212a6ed7025e693afb8009 Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Tue, 3 Feb 2026 16:05:29 -0600 Subject: [PATCH] Fix migrations 008 and 011 to handle removed tags table --- backend/app/database.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/backend/app/database.py b/backend/app/database.py index 6166e22..ec7edbf 100644 --- a/backend/app/database.py +++ b/backend/app/database.py @@ -277,27 +277,8 @@ def _run_migrations(): Migration( name="008_create_tags_ref_count_triggers", sql=""" - DO $$ - BEGIN - DROP TRIGGER IF EXISTS tags_ref_count_insert_trigger ON tags; - CREATE TRIGGER tags_ref_count_insert_trigger - AFTER INSERT ON tags - FOR EACH ROW - EXECUTE FUNCTION increment_artifact_ref_count(); - - DROP TRIGGER IF EXISTS tags_ref_count_delete_trigger ON tags; - CREATE TRIGGER tags_ref_count_delete_trigger - AFTER DELETE ON tags - FOR EACH ROW - EXECUTE FUNCTION decrement_artifact_ref_count(); - - DROP TRIGGER IF EXISTS tags_ref_count_update_trigger ON tags; - CREATE TRIGGER tags_ref_count_update_trigger - AFTER UPDATE ON tags - FOR EACH ROW - WHEN (OLD.artifact_id IS DISTINCT FROM NEW.artifact_id) - EXECUTE FUNCTION update_artifact_ref_count(); - END $$; + -- Tags table removed: triggers no longer needed (tag system removed) + DO $$ BEGIN NULL; END $$; """, ), Migration( @@ -344,9 +325,11 @@ def _run_migrations(): Migration( name="011_migrate_semver_tags_to_versions", sql=r""" + -- Migrate semver tags to versions (only if both tables exist - for existing databases) DO $$ BEGIN - IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'package_versions') THEN + IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'package_versions') + AND EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'tags') THEN INSERT INTO package_versions (id, package_id, artifact_id, version, version_source, created_by, created_at) SELECT gen_random_uuid(),