going somewhere.

This commit is contained in:
didier amyot committed 2022-12-20 10:18:17 -05:00
1 parent 9ccaeaf410
commit d262f0d2f8
6 files changed
+121 -28

No files matched your search

+26 -2
View File
@@ -38,17 +38,41 @@ CREATE TABLE IF NOT EXISTS security_permissions
);
CREATE TABLE IF NOT EXISTS account_types
(
name TEXT PRIMARY KEY
) STRICT;
INSERT INTO account_types(name)
VALUES ('checking'),
('security_emitter');
CREATE TABLE IF NOT EXISTS accounts
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
security INTEGER NOT NULL,
owner INTEGER NOT NULL,
account_type TEXT NOT NULL,
owner INTEGER NOT NULL, -- todo: remove
amount INTEGER NOT NULL,
timestamp DATETIME NOT NULL,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (security) REFERENCES securities (id),
FOREIGN KEY (owner) REFERENCES users (id)
FOREIGN KEY (owner) REFERENCES users (id),
FOREIGN KEY (account_type) REFERENCES account_types (name)
);
CREATE TABLE IF NOT EXISTS account_user_permissions
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
account_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (account_id) REFERENCES account (id),
FOREIGN KEY (user_id) REFERENCES users (id)
);