added accounttypes

This commit is contained in:
jethro 2026-05-13 19:32:50 +12:00
parent d97d852ce9
commit 5e1365799f

View file

@ -10,6 +10,7 @@ id SERIAL PRIMARY KEY,
orgname VARCHAR(50) UNIQUE NOT NULL
)
-- how can I normalize this further? going to end up with lots of nulls in the transactions table, but not sure if it's worth it to have separate tables for each transaction type (e.g. fund transactions, card transactions, etc.)
CREATE TABLE IF NOT EXISTS transactions(
id SERIAL PRIMARY KEY,
datetime DATE NOT NULL,
@ -17,6 +18,7 @@ description VARCHAR NOT NULL,
amount REAL NOT NULL,
accountid INT NOT NULL REFERENCES accounts(id) ON DELETE SET NULL,
orgid INT NOT NULL REFERENCES organizations(id) ON DELETE SET NULL
vendorid INT REFERENCES vendors(id) ON DELETE SET NULL
)
CREATE TABLE IF NOT EXISTS snapshots(
@ -71,6 +73,13 @@ currencycode CHAR(3) UNIQUE NOT NULL,
currencyname VARCHAR(50) NOT NULL
);
--assets, liabilities, equity, income, expenses
CREATE TABLE IF NOT EXISTS accounttypes(
id SERIAL PRIMARY KEY,
typename VARCHAR(100) NOT NULL,
includeinnetworth BOOLEAN NOT NULL
);
CREATE INDEX IF NOT EXISTS rawtransactions_data_idx ON rawtransactions USING GIN (data);
CREATE INDEX IF NOT EXISTS rawtransactions_received_at_idx ON rawtransactions (received_at);
CREATE INDEX IF NOT EXISTS rawtransactions_account_org_idx ON rawtransactions (orgid, accountid);