From 6cc0bfd1d79074df790272b8091b1f0226d14283 Mon Sep 17 00:00:00 2001
From: zwlucas <lucas.fariamo08@gmail.com>
Date: Fri, 29 May 2026 15:57:37 -0300
Subject: feat: upload project

Signed-off-by: zwlucas <lucas.fariamo08@gmail.com>
---
 backend/migrations/schema.sql | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 backend/migrations/schema.sql

(limited to 'backend/migrations/schema.sql')

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
+);
-- 
cgit v1.2.3

