Files
escarmouche/migrations/create_tables_001.sql
T
2022-12-10 17:18:22 -05:00

40 lines
939 B
SQL

CREATE TABLE IF NOT EXISTS users
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
public_key TEXT NOT NULL,
foo INTEGER
);
CREATE TABLE IF NOT EXISTS security_types
(
name TEXT PRIMARY KEY
);
INSERT INTO security_types(name)
VALUES ('currency'), ('bond');
CREATE TABLE IF NOT EXISTS securities
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
security_type TEXT NOT NULL,
name TEXT NOT NULL UNIQUE,
symbol TEXT NOT NULL UNIQUE,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (security_type) REFERENCES security_types (name)
);
CREATE TABLE IF NOT EXISTS account
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
security INTEGER NOT NULL,
owner INTEGER NOT NULL,
FOREIGN KEY (security) REFERENCES securities (id)
);
CREATE TABLE IF NOT EXISTS account_values
(
id INTEGER PRIMARY KEY AUTOINCREMENT
);