|
@@ -58,14 +58,14 @@ def tables(cursor):
|
|
expiry_dt TIMESTAMP NOT NULL,
|
|
expiry_dt TIMESTAMP NOT NULL,
|
|
status VARCHAR(20) NOT NULL,
|
|
status VARCHAR(20) NOT NULL,
|
|
order_id INTEGER NOT NULL, -- order_id is not a FOREIGN KEY since orders are deleted from order table afterwards
|
|
order_id INTEGER NOT NULL, -- order_id is not a FOREIGN KEY since orders are deleted from order table afterwards
|
|
- archived_dt TIMESTAMP NOT NULL DEFAULT (datetime('now','localtime')),
|
|
|
|
|
|
+ archived_dt TIMESTAMP NOT NULL DEFAULT (CAST(strftime('%s', CURRENT_TIMESTAMP) AS INTEGER)),
|
|
FOREIGN KEY (ownership_id) REFERENCES ownership(rowid)
|
|
FOREIGN KEY (ownership_id) REFERENCES ownership(rowid)
|
|
)
|
|
)
|
|
''')
|
|
''')
|
|
cursor.execute('''
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS transactions(
|
|
CREATE TABLE IF NOT EXISTS transactions(
|
|
rowid INTEGER PRIMARY KEY,
|
|
rowid INTEGER PRIMARY KEY,
|
|
- dt TIMESTAMP NOT NULL DEFAULT (datetime('now','localtime')),
|
|
|
|
|
|
+ dt TIMESTAMP NOT NULL DEFAULT (CAST(strftime('%s', CURRENT_TIMESTAMP) AS INTEGER)),
|
|
price CURRENCY NOT NULL,
|
|
price CURRENCY NOT NULL,
|
|
ownable_id INTEGER NOT NULL,
|
|
ownable_id INTEGER NOT NULL,
|
|
amount CURRENCY NOT NULL,
|
|
amount CURRENCY NOT NULL,
|
|
@@ -91,7 +91,7 @@ def tables(cursor):
|
|
cursor.execute('''
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS news(
|
|
CREATE TABLE IF NOT EXISTS news(
|
|
rowid INTEGER PRIMARY KEY,
|
|
rowid INTEGER PRIMARY KEY,
|
|
- dt TIMESTAMP NOT NULL DEFAULT (datetime('now','localtime')),
|
|
|
|
|
|
+ dt TIMESTAMP NOT NULL DEFAULT (CAST(strftime('%s', CURRENT_TIMESTAMP) AS INTEGER)),
|
|
title VARCHAR(50) NOT NULL
|
|
title VARCHAR(50) NOT NULL
|
|
)
|
|
)
|
|
''')
|
|
''')
|
|
@@ -104,7 +104,7 @@ def tables(cursor):
|
|
cursor.execute('''
|
|
cursor.execute('''
|
|
CREATE TABLE IF NOT EXISTS global_control_values(
|
|
CREATE TABLE IF NOT EXISTS global_control_values(
|
|
rowid INTEGER PRIMARY KEY,
|
|
rowid INTEGER PRIMARY KEY,
|
|
- dt TIMESTAMP NOT NULL DEFAULT (datetime('now','localtime')),
|
|
|
|
|
|
+ dt TIMESTAMP NOT NULL DEFAULT (CAST(strftime('%s', CURRENT_TIMESTAMP) AS INTEGER)),
|
|
value_name VARCHAR NOT NULL,
|
|
value_name VARCHAR NOT NULL,
|
|
value FLOAT NOT NULL,
|
|
value FLOAT NOT NULL,
|
|
UNIQUE (value_name, dt)
|
|
UNIQUE (value_name, dt)
|
|
@@ -116,10 +116,19 @@ def tables(cursor):
|
|
user_id INTEGER NOT NULL REFERENCES users(rowid),
|
|
user_id INTEGER NOT NULL REFERENCES users(rowid),
|
|
total_amount CURRENCY NOT NULL, -- TODO trigger that total amount is strictly larger 0
|
|
total_amount CURRENCY NOT NULL, -- TODO trigger that total amount is strictly larger 0
|
|
amount CURRENCY NOT NULL, -- TODO trigger that amount is strictly larger 0
|
|
amount CURRENCY NOT NULL, -- TODO trigger that amount is strictly larger 0
|
|
- last_interest_pay_dt TIMESTAMP NOT NULL DEFAULT (datetime('now','localtime')),
|
|
|
|
|
|
+ last_interest_pay_dt TIMESTAMP NOT NULL DEFAULT (CAST(strftime('%s', CURRENT_TIMESTAMP) AS INTEGER)),
|
|
interest_rate CURRENCY NOT NULL -- determined from the global value 'personal_loan_interest_rate'
|
|
interest_rate CURRENCY NOT NULL -- determined from the global value 'personal_loan_interest_rate'
|
|
)
|
|
)
|
|
''')
|
|
''')
|
|
|
|
+ cursor.execute('''
|
|
|
|
+ CREATE TABLE IF NOT EXISTS bonds(
|
|
|
|
+ rowid INTEGER PRIMARY KEY,
|
|
|
|
+ issuer_id INTEGER NOT NULL REFERENCES users(rowid),
|
|
|
|
+ ownable_id INTEGER UNIQUE NOT NULL REFERENCES ownables(rowid),
|
|
|
|
+ last_interest_pay_dt TIMESTAMP NOT NULL DEFAULT (CAST(strftime('%s', CURRENT_TIMESTAMP) AS INTEGER)),
|
|
|
|
+ coupon CURRENCY NOT NULL -- fancy word for interest rate
|
|
|
|
+ )
|
|
|
|
+ ''')
|
|
_add_column_if_not_exists(cursor, '''
|
|
_add_column_if_not_exists(cursor, '''
|
|
-- there is a not null constraint for new values that is watched by triggers
|
|
-- there is a not null constraint for new values that is watched by triggers
|
|
ALTER TABLE users ADD COLUMN salt BLOB NOT NULL DEFAULT 'orderer_is_a_cool_application_]{][{²$%WT§$%GV§$%SF$%&S$%FGGFHBDHJZIF254325'
|
|
ALTER TABLE users ADD COLUMN salt BLOB NOT NULL DEFAULT 'orderer_is_a_cool_application_]{][{²$%WT§$%GV§$%SF$%&S$%FGGFHBDHJZIF254325'
|