diff options
Diffstat (limited to 'backend/migrations')
| -rw-r--r-- | backend/migrations/schema.sql | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/backend/migrations/schema.sql b/backend/migrations/schema.sql new file mode 100644 index 0000000..eba89db --- /dev/null +++ b/backend/migrations/schema.sql @@ -0,0 +1,34 @@ +CREATE TABLE IF NOT EXISTS services ( + id SERIAL PRIMARY KEY, + name VARCHAR(255) NOT NULL, + url TEXT NOT NULL, + group_name VARCHAR(255) NOT NULL DEFAULT 'Geral', + interval_seconds INTEGER NOT NULL DEFAULT 60, + is_active BOOLEAN NOT NULL DEFAULT true, + discord_webhook_url TEXT NOT NULL DEFAULT '', + alert_email TEXT NOT NULL DEFAULT '', + keyword_to_find TEXT NOT NULL DEFAULT '', + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE TABLE IF NOT EXISTS heartbeats ( + id SERIAL PRIMARY KEY, + service_id INTEGER NOT NULL REFERENCES services(id) ON DELETE CASCADE, + status_code INTEGER NOT NULL DEFAULT 0, + response_time_ms BIGINT NOT NULL DEFAULT 0, + is_up BOOLEAN NOT NULL DEFAULT false, + error_message TEXT NOT NULL DEFAULT '', + tested_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS idx_heartbeats_service_id ON heartbeats(service_id); +CREATE INDEX IF NOT EXISTS idx_heartbeats_tested_at ON heartbeats(tested_at DESC); +CREATE INDEX IF NOT EXISTS idx_services_is_active ON services(is_active); + +CREATE TABLE IF NOT EXISTS maintenances ( + id SERIAL PRIMARY KEY, + title TEXT NOT NULL, + start_time TIMESTAMPTZ NOT NULL, + end_time TIMESTAMPTZ NOT NULL, + is_active BOOLEAN NOT NULL DEFAULT true +); |