Release v2.2.3: migration 138 integer compatibility hotfix

This commit is contained in:
Christian 2026-02-22 03:35:56 +01:00
parent e772311a86
commit abd5014eb0
3 changed files with 42 additions and 9 deletions

15
RELEASE_NOTES_v2.2.3.md Normal file
View File

@ -0,0 +1,15 @@
# BMC Hub v2.2.3 - Migration Hotfix
**Release Date:** 22. februar 2026
## 🛠️ Hotfix
### Migration 138 compatibility fix
- Fixed `migrations/138_customers_economic_unique_constraint.sql` for environments where `customers.economic_customer_number` is numeric (`integer`).
- Removed unconditional `btrim(...)` usage on non-text columns.
- Added type-aware normalization logic that only applies trimming for text-like column types.
## ✅ Impact
- Migration `138_customers_economic_unique_constraint.sql` now runs on both numeric and text column variants without `function btrim(integer) does not exist` errors.
- Unique index safety behavior and duplicate detection are unchanged.

View File

@ -1 +1 @@
2.2.2 2.2.3

View File

@ -1,15 +1,33 @@
-- Migration: Enforce unique economic customer number on customers -- Migration: Enforce unique economic customer number on customers
-- Prevents ambiguous mapping during e-conomic sync -- Prevents ambiguous mapping during e-conomic sync
-- Normalize values before uniqueness check -- Normalize values before uniqueness check (only for text-like columns)
UPDATE customers DO $$
SET economic_customer_number = NULL DECLARE
WHERE economic_customer_number IS NOT NULL column_data_type TEXT;
AND btrim(economic_customer_number) = ''; BEGIN
SELECT data_type
INTO column_data_type
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'customers'
AND column_name = 'economic_customer_number';
UPDATE customers IF column_data_type IN ('character varying', 'character', 'text') THEN
SET economic_customer_number = btrim(economic_customer_number) EXECUTE $$
WHERE economic_customer_number IS NOT NULL; UPDATE customers
SET economic_customer_number = NULL
WHERE economic_customer_number IS NOT NULL
AND btrim(economic_customer_number) = ''
$$;
EXECUTE $$
UPDATE customers
SET economic_customer_number = btrim(economic_customer_number)
WHERE economic_customer_number IS NOT NULL
$$;
END IF;
END $$;
-- Abort migration if duplicates exist (must be manually resolved first) -- Abort migration if duplicates exist (must be manually resolved first)
DO $$ DO $$