Files
ewoooc/migrations/033_fix_host_health_probe_labels.sql

39 lines
1.5 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================================
-- 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-SSDvia Nginx 110,
-- GCP-SSD-2via 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-SSDvia Nginx 110',
'GCP-SSD-2via 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()';