39 lines
1.5 KiB
SQL
39 lines
1.5 KiB
SQL
-- =============================================================================
|
||
-- Migration 033: host_health_probes host_label CHECK alignment
|
||
-- 2026-05-12 Taipei
|
||
-- =============================================================================
|
||
-- Context:
|
||
-- Migration 029 only allowed the original dashboard labels:
|
||
-- Primary (GCP), Secondary (GCP), Fallback (111)
|
||
-- services/ollama_service.py::get_host_label() later added operational labels:
|
||
-- GCP-SSD, GCP-SSD-2, 111 備援, GCP-SSD(via Nginx 110),
|
||
-- GCP-SSD-2(via Nginx 110)
|
||
--
|
||
-- Keep the existing constraint name to avoid downstream drift, but widen the
|
||
-- allowed set. NOT VALID avoids failing on any historical probe rows while still
|
||
-- enforcing the widened CHECK for future inserts.
|
||
-- =============================================================================
|
||
|
||
ALTER TABLE IF EXISTS host_health_probes
|
||
DROP CONSTRAINT IF EXISTS chk_host_label_029;
|
||
|
||
ALTER TABLE IF EXISTS host_health_probes
|
||
ADD CONSTRAINT chk_host_label_029
|
||
CHECK (
|
||
host_label IN (
|
||
'Primary (GCP)',
|
||
'Secondary (GCP)',
|
||
'Fallback (111)',
|
||
'GCP-SSD',
|
||
'GCP-SSD-2',
|
||
'111 備援',
|
||
'GCP-SSD(via Nginx 110)',
|
||
'GCP-SSD-2(via Nginx 110)',
|
||
'188 本地',
|
||
'未知'
|
||
)
|
||
) NOT VALID;
|
||
|
||
COMMENT ON CONSTRAINT chk_host_label_029 ON host_health_probes IS
|
||
'Accepted labels from migration 029 dashboard probes and services/ollama_service.py::get_host_label()';
|