Files
btcdata/resources/migrations/20260308000000-create-deposits.up.sql
T
magnusandClaude Opus 4.6 174ea24786 Add deposits read table (CQRS projection from bank_to_exchange events)
Project each bank_to_exchange event into a denormalized deposits table
with pre-computed EUR, DKK, and USD amounts using Frankfurter currency
rates. Replaces the aggregate get-deposit-totals query.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 12:52:32 +01:00

13 lines
364 B
SQL

CREATE TABLE deposits (
id BIGSERIAL PRIMARY KEY,
event_id BIGINT NOT NULL REFERENCES events(id) UNIQUE,
occurred_at TIMESTAMPTZ NOT NULL,
exchange TEXT NOT NULL,
fiat_amount NUMERIC(18,2) NOT NULL,
fiat_currency TEXT NOT NULL,
amount_eur NUMERIC(18,2),
amount_dkk NUMERIC(18,2),
amount_usd NUMERIC(18,2),
note TEXT
);