From d97d852ce993bf15633318a3b23ba73d7263af36 Mon Sep 17 00:00:00 2001 From: jethro Date: Wed, 13 May 2026 19:21:00 +1200 Subject: [PATCH] added funds table, currency table --- sql/database definitions.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sql/database definitions.sql b/sql/database definitions.sql index 3941c76..3003f64 100644 --- a/sql/database definitions.sql +++ b/sql/database definitions.sql @@ -51,6 +51,26 @@ raw_sha256 CHAR(64) UNIQUE, processed BOOLEAN NOT NULL DEFAULT FALSE ); + +CREATE TABLE IF NOT EXISTS funds( +id SERIAL PRIMARY KEY, +name VARCHAR(100) NOT NULL, +datetime DATE 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, +fundid VARCHAR(100) NOT NULL, +value REAL NOT NULL, +shares REAL NOT NULL, +currencyid INT REFERENCES currency(id) ON DELETE SET NULL +); + +CREATE TABLE IF NOT EXISTS currency( +id SERIAL PRIMARY KEY, +currencycode CHAR(3) UNIQUE NOT NULL, +currencyname VARCHAR(50) 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