You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
862 B

package am
var migration = `
CREATE TABLE IF NOT EXISTS users(
Username TEXT NOT NULL PRIMARY KEY,
Password TEXT NOT NULL,
Admin BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS sources(
SourceID TEXT NOT NULL PRIMARY KEY,
Name TEXT NOT NULL UNIQUE,
APIKey TEXT NOT NULL UNIQUE,
Description TEXT NOT NULL,
LastSeenAt TIMESTAMP NOT NULL,
AlertedAt TIMESTAMP NOT NULL,
AlertTimeout BIGINT NOT NULL
);
CREATE TABLE IF NOT EXISTS log(
LogID INTEGER PRIMARY KEY AUTOINCREMENT,
SourceID TEXT NOT NULL REFERENCES sources(SourceID) ON DELETE CASCADE,
TS TIMESTAMP NOT NULL,
Alert BOOLEAN NOT NULL,
Text TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS log_ts_idx ON log(TS);
CREATE INDEX IF NOT EXISTS log_source_ts_idx ON log(SourceID, TS);
`