diff options
Diffstat (limited to 'pkg/database/sql/000_init.sql')
-rw-r--r-- | pkg/database/sql/000_init.sql | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/database/sql/000_init.sql b/pkg/database/sql/000_init.sql index ab40746..c56473f 100644 --- a/pkg/database/sql/000_init.sql +++ b/pkg/database/sql/000_init.sql @@ -2,6 +2,17 @@ CREATE TABLE schema_version ( version INTEGER NOT NULL ) STRICT; +CREATE TABLE accounts ( + id INTEGER PRIMARY KEY, + username TEXT NOT NULL, + password BLOB NOT NULL, + is_admin INTEGER NOT NULL DEFAULT FALSE, + created INTEGER NOT NULL DEFAULT (unixepoch()), + last_login INTEGER NOT NULL DEFAULT (unixepoch()), + settings TEXT +) STRICT; +CREATE UNIQUE INDEX accounts_username on accounts(username); + CREATE TABLE states ( id INTEGER PRIMARY KEY, path TEXT NOT NULL, @@ -11,9 +22,11 @@ CREATE UNIQUE INDEX states_path on states(path); CREATE TABLE versions ( id INTEGER PRIMARY KEY, + account_id INTEGER NOT NULL, state_id INTEGER, data BLOB, lock TEXT, created INTEGER DEFAULT (unixepoch()), + FOREIGN KEY(account_id) REFERENCES accounts(id) ON DELETE CASCADE FOREIGN KEY(state_id) REFERENCES states(id) ON DELETE CASCADE ) STRICT; |