CREATE TABLE IF NOT EXISTS alert_creation_requests ( idempotency_key VARCHAR(255) PRIMARY KEY, request_hash CHAR(64) NOT NULL, alert_id INTEGER REFERENCES alerts(id) ON DELETE SET NULL, response_body JSONB, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE INDEX IF NOT EXISTS idx_alert_creation_requests_created_at ON alert_creation_requests(created_at);