Files
haproxy-openmanager/backend/database
taylanbakircioglu 6c24971c19 Migration: Convert use_backend_rules to JSONB for consistency
Database Type Consistency Fix:
- acl_rules: JSONB ✓
- redirect_rules: JSONB ✓
- use_backend_rules: TEXT ✗ (INCONSISTENT!)

Issue:
  Different data types cause:
  - JSON serialization inconsistencies
  - Query performance differences
  - Potential data corruption

Fix Applied:

1. CREATE TABLE (Line 2038):
   Changed: use_backend_rules TEXT
   To: use_backend_rules JSONB DEFAULT '[]'::jsonb

2. ALTER TABLE (Line 121):
   Changed: ADD COLUMN use_backend_rules TEXT
   To: ADD COLUMN use_backend_rules JSONB DEFAULT '[]'::jsonb

3. Type Conversion Migration (Line 2318-2334):
   Added automatic conversion from TEXT to JSONB
   Handles: NULL, empty string, existing JSON data
   Safe conversion with CASE statement

Migration Logic:
  IF column type is TEXT or VARCHAR:
    - NULL → '[]'::jsonb
    - Empty string → '[]'::jsonb
    - Existing JSON → Parse to JSONB
    - Invalid data → Fails gracefully

Benefits:
  - Consistent JSONB type across all rule fields
  - Better query performance (JSONB indexing)
  - Type safety in application code
  - Automatic array validation

Impact: SAFE - Migration runs automatically on startup
2025-11-07 11:51:15 +03:00
..
2025-10-27 12:14:03 +03:00
2025-10-27 12:14:03 +03:00