-- Ping Flap Suppression Table
-- Tracks ping targets that have been auto-suppressed due to flapping behaviour.
-- Used to prevent repeated Zabbix suppression calls and pipeline noise.

CREATE TABLE IF NOT EXISTS ping_flap_suppressions (
    ping_target     TEXT PRIMARY KEY,
    trigger_count   INTEGER NOT NULL,
    suppressed_until TIMESTAMP NOT NULL,
    zabbix_suppressed BOOLEAN NOT NULL DEFAULT false,
    notes           TEXT,
    updated_at      TIMESTAMP NOT NULL DEFAULT NOW(),
    created_at      TIMESTAMP NOT NULL DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_ping_flap_suppressions_until ON ping_flap_suppressions(suppressed_until);

COMMENT ON TABLE ping_flap_suppressions IS 'Tracks auto-suppressed flapping ping targets. Suppression expires at suppressed_until.';
