mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-29 10:41:19 +00:00
60 lines
1.4 KiB
SQL
60 lines
1.4 KiB
SQL
-- +migrate Up
|
|
CREATE TABLE oauth2_states (
|
|
state TEXT,
|
|
expires_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
PRIMARY KEY (state)
|
|
);
|
|
|
|
CREATE TABLE monitors (
|
|
slug TEXT,
|
|
name TEXT,
|
|
schedule TEXT,
|
|
script TEXT,
|
|
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at DATETIME,
|
|
|
|
PRIMARY KEY (slug),
|
|
CONSTRAINT unique_monitors_name UNIQUE (name)
|
|
);
|
|
|
|
CREATE TABLE worker_groups (
|
|
slug TEXT,
|
|
name TEXT,
|
|
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at DATETIME,
|
|
|
|
PRIMARY KEY (slug),
|
|
CONSTRAINT unique_worker_groups_name UNIQUE (name)
|
|
);
|
|
|
|
CREATE TABLE monitor_worker_groups (
|
|
worker_group_slug TEXT,
|
|
monitor_slug TEXT,
|
|
|
|
PRIMARY KEY (worker_group_slug,monitor_slug),
|
|
CONSTRAINT fk_monitor_worker_groups_worker_group FOREIGN KEY (worker_group_slug) REFERENCES worker_groups(slug),
|
|
CONSTRAINT fk_monitor_worker_groups_monitor FOREIGN KEY (monitor_slug) REFERENCES monitors(slug)
|
|
);
|
|
|
|
CREATE TABLE monitor_histories (
|
|
monitor_slug TEXT,
|
|
status TEXT,
|
|
note TEXT,
|
|
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
PRIMARY KEY (monitor_slug, created_at),
|
|
CONSTRAINT fk_monitors_history FOREIGN KEY (monitor_slug) REFERENCES monitors(slug)
|
|
);
|
|
|
|
-- +migrate Down
|
|
DROP TABLE oauth2_states;
|
|
DROP TABLE monitor_worker_groups;
|
|
DROP TABLE worker_groups;
|
|
DROP TABLE monitor_histories;
|
|
DROP TABLE monitors;
|