diff options
| author | Kevin Hoerr <kjhoerr@submelon.dev> | 2025-11-17 02:43:27 -0500 |
|---|---|---|
| committer | Kevin Hoerr <kjhoerr@submelon.dev> | 2025-11-17 02:43:27 -0500 |
| commit | 5ec98d322f00c63c6ff490f86af051eed1149d8c (patch) | |
| tree | 66e55bbb92d56e7c199598abb907b4ff03d73e9b /src/main/resources/db | |
| parent | 8434854c50576e41008139be73e7fdb2b4b5f1cd (diff) | |
| download | equity-tracker-5ec98d322f00c63c6ff490f86af051eed1149d8c.tar.gz equity-tracker-5ec98d322f00c63c6ff490f86af051eed1149d8c.tar.bz2 equity-tracker-5ec98d322f00c63c6ff490f86af051eed1149d8c.zip | |
20251114-0-init-schema.sql: Add computed stored fields for equity_change_event table
Diffstat (limited to 'src/main/resources/db')
| -rw-r--r-- | src/main/resources/db/20251114-0-init-schema.sql | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main/resources/db/20251114-0-init-schema.sql b/src/main/resources/db/20251114-0-init-schema.sql index b9b921f..886a961 100644 --- a/src/main/resources/db/20251114-0-init-schema.sql +++ b/src/main/resources/db/20251114-0-init-schema.sql @@ -47,7 +47,7 @@ create table equity_change_event equity_change_cost_basis_usd DECIMAL(14, 2) NOT NULL, equity_change_type VARCHAR(20) NOT NULL CHECK (equity_change_type IN ('BUY', 'SELL')), -- This is essentially '+' or '-' - equity_change_timestamp TIMESTAMP NOT NULL + equity_change_timestamp TIMESTAMP NOT NULL, + equity_change_type_score NUMERIC AS (CASE WHEN equity_change_type = 'BUY' THEN 1.0 ELSE -1.0 END) STORED, + equity_change_est_price DECIMAL(14, 2) AS (equity_change_cost_basis_usd / equity_change_quantity) STORED ); - ---TODO construct views on event collation? heavy calculation requirements....
\ No newline at end of file |
