19 lines
741 B
MySQL
19 lines
741 B
MySQL
|
|
-- Drift: explicit monitor->customer mappings for Uptime Kuma events
|
||
|
|
|
||
|
|
CREATE TABLE IF NOT EXISTS drift_customer_mappings (
|
||
|
|
id SERIAL PRIMARY KEY,
|
||
|
|
source_id INTEGER REFERENCES drift_sources(id) ON DELETE CASCADE,
|
||
|
|
monitor_key VARCHAR(255),
|
||
|
|
monitor_name VARCHAR(255),
|
||
|
|
customer_id INTEGER NOT NULL REFERENCES customers(id) ON DELETE CASCADE,
|
||
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
UNIQUE (source_id, monitor_key)
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_drift_customer_mappings_source_id
|
||
|
|
ON drift_customer_mappings(source_id);
|
||
|
|
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_drift_customer_mappings_customer_id
|
||
|
|
ON drift_customer_mappings(customer_id);
|