From d304877a8354c529779dab5d7898095f9c32fa1c Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Thu, 19 Mar 2026 12:57:14 +0100 Subject: [PATCH] fix: re-normalize series statuses with UI-added mappings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migration 0041 re-applies status normalization using all current status_mappings entries, including those added via the UI after the initial migration 0039 (e.g. "one shot" → "ended"). Co-Authored-By: Claude Opus 4.6 --- .../0041_renormalize_with_current_mappings.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 infra/migrations/0041_renormalize_with_current_mappings.sql diff --git a/infra/migrations/0041_renormalize_with_current_mappings.sql b/infra/migrations/0041_renormalize_with_current_mappings.sql new file mode 100644 index 0000000..d44625f --- /dev/null +++ b/infra/migrations/0041_renormalize_with_current_mappings.sql @@ -0,0 +1,18 @@ +-- Re-normalize series_metadata.status using current status_mappings. +-- Catches mappings added via UI after migration 0039 ran (e.g. "one shot" → "ended"). + +-- Exact match +UPDATE series_metadata sm +SET status = m.mapped_status, updated_at = NOW() +FROM status_mappings m +WHERE LOWER(sm.status) = m.provider_status + AND sm.status IS NOT NULL + AND LOWER(sm.status) != m.mapped_status; + +-- Substring match +UPDATE series_metadata sm +SET status = m.mapped_status, updated_at = NOW() +FROM status_mappings m +WHERE LOWER(sm.status) LIKE '%' || m.provider_status || '%' + AND sm.status IS NOT NULL + AND LOWER(sm.status) != m.mapped_status;