2024-02-27 11:04:05 +00:00
|
|
|
-- +migrate Up
|
2024-02-27 14:43:20 +00:00
|
|
|
CREATE TABLE oauth2_states (
|
2024-02-27 14:55:35 +00:00
|
|
|
state TEXT,
|
|
|
|
expires_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
2024-02-27 11:04:05 +00:00
|
|
|
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,
|
2024-02-27 14:55:35 +00:00
|
|
|
monitor_slug TEXT,
|
|
|
|
|
2024-02-27 11:04:05 +00:00
|
|
|
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)
|
|
|
|
);
|
|
|
|
|
2024-02-27 14:43:20 +00:00
|
|
|
CREATE TABLE monitor_histories (
|
2024-02-27 11:04:05 +00:00
|
|
|
monitor_slug TEXT,
|
2024-02-27 14:55:35 +00:00
|
|
|
status TEXT,
|
|
|
|
note TEXT,
|
2024-02-27 11:04:05 +00:00
|
|
|
|
|
|
|
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
|
2024-02-27 14:43:20 +00:00
|
|
|
DROP TABLE oauth2_states;
|
2024-02-27 11:04:05 +00:00
|
|
|
DROP TABLE monitor_worker_groups;
|
|
|
|
DROP TABLE worker_groups;
|
|
|
|
DROP TABLE monitor_histories;
|
|
|
|
DROP TABLE monitors;
|