diff --git a/backend/drizzle/0008_alert_outbox_outcomes.sql b/backend/drizzle/0008_alert_outbox_outcomes.sql index 60ebf17b..4f8b89a6 100644 --- a/backend/drizzle/0008_alert_outbox_outcomes.sql +++ b/backend/drizzle/0008_alert_outbox_outcomes.sql @@ -1,6 +1,6 @@ --- Захват перед POST и удержание неизвестных исходов. Исторические строки не меняются. -BEGIN; -ALTER TABLE alert_outbox DROP CONSTRAINT IF EXISTS alert_outbox_status_check; -ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_status_check - CHECK (status IN ('pending', 'processing', 'unknown', 'sent', 'failed')); -COMMIT; +-- Захват перед POST и удержание неизвестных исходов. Исторические строки не меняются. +BEGIN; +ALTER TABLE alert_outbox DROP CONSTRAINT IF EXISTS alert_outbox_status_check; +ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_status_check + CHECK (status IN ('pending', 'processing', 'unknown', 'sent', 'failed')); +COMMIT; diff --git a/backend/drizzle/0009_alert_outbox_resolution.sql b/backend/drizzle/0009_alert_outbox_resolution.sql index fbedccf1..f8af6ff2 100644 --- a/backend/drizzle/0009_alert_outbox_resolution.sql +++ b/backend/drizzle/0009_alert_outbox_resolution.sql @@ -1,4 +1,4 @@ -BEGIN; -ALTER TABLE alert_outbox ADD COLUMN IF NOT EXISTS resolution_version integer NOT NULL DEFAULT 0; -ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_resolution_version_check CHECK (resolution_version >= 0); -COMMIT; +BEGIN; +ALTER TABLE alert_outbox ADD COLUMN IF NOT EXISTS resolution_version integer NOT NULL DEFAULT 0; +ALTER TABLE alert_outbox ADD CONSTRAINT alert_outbox_resolution_version_check CHECK (resolution_version >= 0); +COMMIT; diff --git a/backend/drizzle/0010_ping_measurement_known.sql b/backend/drizzle/0010_ping_measurement_known.sql index 239552e7..10a55fdc 100644 --- a/backend/drizzle/0010_ping_measurement_known.sql +++ b/backend/drizzle/0010_ping_measurement_known.sql @@ -1,3 +1,3 @@ --- A failed command is an attempt, not a measured packet-loss percentage. -ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS measurement_known BOOLEAN NOT NULL DEFAULT true; -ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS observation_error TEXT; +-- A failed command is an attempt, not a measured packet-loss percentage. +ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS measurement_known BOOLEAN NOT NULL DEFAULT true; +ALTER TABLE uptime_probe_samples ADD COLUMN IF NOT EXISTS observation_error TEXT; diff --git a/backend/drizzle/0011_traffic_collection_state.sql b/backend/drizzle/0011_traffic_collection_state.sql index f5c5245f..78331da4 100644 --- a/backend/drizzle/0011_traffic_collection_state.sql +++ b/backend/drizzle/0011_traffic_collection_state.sql @@ -1,8 +1,8 @@ -CREATE TABLE IF NOT EXISTS traffic_collection_state ( - server_id BIGINT PRIMARY KEY REFERENCES servers(id) ON DELETE CASCADE, - server_updated_at TIMESTAMPTZ NOT NULL, - last_attempt_at TIMESTAMPTZ NOT NULL, - last_succeeded_at TIMESTAMPTZ, - status TEXT NOT NULL CHECK(status IN ('pending', 'ok', 'error')), - error TEXT -); +CREATE TABLE IF NOT EXISTS traffic_collection_state ( + server_id BIGINT PRIMARY KEY REFERENCES servers(id) ON DELETE CASCADE, + server_updated_at TIMESTAMPTZ NOT NULL, + last_attempt_at TIMESTAMPTZ NOT NULL, + last_succeeded_at TIMESTAMPTZ, + status TEXT NOT NULL CHECK(status IN ('pending', 'ok', 'error')), + error TEXT +); diff --git a/backend/drizzle/0012_traffic_counter_identity.sql b/backend/drizzle/0012_traffic_counter_identity.sql index 9d48866b..dcb7de8d 100644 --- a/backend/drizzle/0012_traffic_counter_identity.sql +++ b/backend/drizzle/0012_traffic_counter_identity.sql @@ -1 +1 @@ -ALTER TABLE traffic_samples ADD COLUMN IF NOT EXISTS native_counter_identity TEXT; +ALTER TABLE traffic_samples ADD COLUMN IF NOT EXISTS native_counter_identity TEXT; diff --git a/backend/drizzle/0013_scheduler_retention_index.sql b/backend/drizzle/0013_scheduler_retention_index.sql index ec1ef14d..a0e12c57 100644 --- a/backend/drizzle/0013_scheduler_retention_index.sql +++ b/backend/drizzle/0013_scheduler_retention_index.sql @@ -1,4 +1,4 @@ --- Retention runs after each scheduler receipt; avoid scanning the complete history. --- On a busy existing installation, pre-create this same index CONCURRENTLY --- outside a transaction before deploying (deploy/PRODUCTION-RETENTION-INDEX.md). -CREATE INDEX IF NOT EXISTS idx_scheduler_runs_finished_at ON scheduler_runs (finished_at); +-- Retention runs after each scheduler receipt; avoid scanning the complete history. +-- On a busy existing installation, pre-create this same index CONCURRENTLY +-- outside a transaction before deploying (deploy/PRODUCTION-RETENTION-INDEX.md). +CREATE INDEX IF NOT EXISTS idx_scheduler_runs_finished_at ON scheduler_runs (finished_at);