aboutsummaryrefslogtreecommitdiff
path: root/backend/migrations
diff options
context:
space:
mode:
authorzwlucas <lucas.fariamo08@gmail.com>2026-05-29 18:57:37 +0000
committerzwlucas <lucas.fariamo08@gmail.com>2026-05-29 18:57:37 +0000
commit6cc0bfd1d79074df790272b8091b1f0226d14283 (patch)
treecab18b0f708cf3b0eaeeeb98e2cf81459365b33e /backend/migrations
downloadyaum-6cc0bfd1d79074df790272b8091b1f0226d14283.tar.gz
yaum-6cc0bfd1d79074df790272b8091b1f0226d14283.zip
feat: upload project
Signed-off-by: zwlucas <lucas.fariamo08@gmail.com>
Diffstat (limited to 'backend/migrations')
-rw-r--r--backend/migrations/schema.sql34
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
+);