CREATE TABLE checks (
    id SERIAL PRIMARY KEY,
    name TEXT NOT NULL,
    type TEXT NOT NULL, -- script | docker_container | docker_network
    description TEXT,
    target TEXT,
    script_name TEXT,
    schedule_seconds INTEGER DEFAULT 60,
    timeout_seconds INTEGER DEFAULT 20,
    active BOOLEAN DEFAULT TRUE,
    last_run TIMESTAMP,
    last_status TEXT
);

CREATE TABLE results (
    id SERIAL PRIMARY KEY,
    check_id INTEGER REFERENCES checks(id) ON DELETE CASCADE,
    run_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    status TEXT,
    message TEXT,
    duration_ms INTEGER
);

INSERT INTO checks (name, type, description, target)
VALUES
('Google HTTP', 'script', 'Prüft google.com', NULL),
('Postgres Container Running', 'docker_container', 'Ist Postgres Container aktiv?', 'info-postgres'),
('Default Network contains Postgres', 'docker_network', 'Ist Postgres im default Netzwerk?', 'bridge');
