mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-22 15:53:45 +00:00
29 lines
770 B
SQL
29 lines
770 B
SQL
-- +migrate Up
|
|
CREATE TABLE triggers (
|
|
id TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
script TEXT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
|
|
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ')),
|
|
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ')),
|
|
|
|
PRIMARY KEY (id),
|
|
CONSTRAINT unique_triggers_name UNIQUE (name)
|
|
) STRICT;
|
|
|
|
CREATE TABLE trigger_histories (
|
|
trigger_id TEXT NOT NULL,
|
|
|
|
status TEXT NOT NULL,
|
|
note TEXT NOT NULL,
|
|
|
|
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ')),
|
|
|
|
PRIMARY KEY (trigger_id, created_at),
|
|
CONSTRAINT fk_trigger_histories_trigger FOREIGN KEY (trigger_id) REFERENCES triggers(id) ON DELETE CASCADE
|
|
) STRICT;
|
|
|
|
-- +migrate Down
|
|
DROP TABLE triggers;
|
|
DROP TABLE trigger_histories;
|