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>
13 lines
364 B
SQL
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
|
|
);
|