added some more tables for the db schema after discovering ideas while coding

This commit is contained in:
jethro 2026-05-13 19:01:06 +12:00
parent 32e64d65c6
commit c06e926627

View file

@ -18,3 +18,38 @@ amount REAL NOT NULL,
accountid INT NOT NULL --foreign key from accounts accountid INT NOT NULL --foreign key from accounts
orgid INT NOT NULL --foreign key from organizations orgid INT NOT NULL --foreign key from organizations
) )
CREATE TABLE IF NOT EXISTS snapshots(
id SERIAL PRIMARY KEY,
datetime DATE NOT NULL,
accountid INT NOT NULL, --foreign key from accounts
balance REAL NOT NULL,
orgid INT NOT NULL --foreign key from organizations
)
CREATE TABLE IF NOT EXISTS syncs(
id SERIAL PRIMARY KEY,
datetime DATE NOT NULL,
accountid INT NOT NULL, --foreign key from accounts
orgid INT NOT NULL --foreign key from organizations
)
CREATE TABLE IF NOT EXISTS vendors(
id SERIAL PRIMARY KEY,
vendorname VARCHAR NOT NULL,
)
CREATE TABLE IF NOT EXISTS rawtransactions(
id SERIAL PRIMARY KEY,
data JSONB NOT NULL,
received_at TIMESTAMPTZ NOT NULL DEFAULT now(),
source VARCHAR(100),
accountid INT REFERENCES accounts(id) ON DELETE SET NULL,
orgid INT REFERENCES organizations(id) ON DELETE SET NULL,
raw_sha256 CHAR(64) UNIQUE,
processed BOOLEAN NOT NULL DEFAULT FALSE
);
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);