From 5e1365799fb57f47a2343ea4c2a3c9a2f9325088 Mon Sep 17 00:00:00 2001 From: jethro Date: Wed, 13 May 2026 19:32:50 +1200 Subject: [PATCH] added accounttypes --- sql/database definitions.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sql/database definitions.sql b/sql/database definitions.sql index 3003f64..2a4e016 100644 --- a/sql/database definitions.sql +++ b/sql/database definitions.sql @@ -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); \ No newline at end of file