Release v2.2.3: migration 138 integer compatibility hotfix
This commit is contained in:
parent
e772311a86
commit
abd5014eb0
15
RELEASE_NOTES_v2.2.3.md
Normal file
15
RELEASE_NOTES_v2.2.3.md
Normal 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.
|
||||
@ -1,15 +1,33 @@
|
||||
-- Migration: Enforce unique economic customer number on customers
|
||||
-- Prevents ambiguous mapping during e-conomic sync
|
||||
|
||||
-- Normalize values before uniqueness check
|
||||
UPDATE customers
|
||||
SET economic_customer_number = NULL
|
||||
WHERE economic_customer_number IS NOT NULL
|
||||
AND btrim(economic_customer_number) = '';
|
||||
-- Normalize values before uniqueness check (only for text-like columns)
|
||||
DO $$
|
||||
DECLARE
|
||||
column_data_type TEXT;
|
||||
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
|
||||
SET economic_customer_number = btrim(economic_customer_number)
|
||||
WHERE economic_customer_number IS NOT NULL;
|
||||
IF column_data_type IN ('character varying', 'character', 'text') THEN
|
||||
EXECUTE $$
|
||||
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)
|
||||
DO $$
|
||||
|
||||
Loading…
Reference in New Issue
Block a user