Denormalized read table with id, event_id, occurred_at, wallet, sats, fee_sats, and amount_eur. Projected on event creation and rebuildable via POST /api/buys/rebuild. Fiat amounts converted to EUR using Frankfurter rates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8 lines
215 B
SQL
8 lines
215 B
SQL
CREATE TABLE buys (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
event_id BIGINT NOT NULL REFERENCES events(id) UNIQUE,
|
|
occurred_at DATE NOT NULL,
|
|
wallet TEXT NOT NULL,
|
|
amount_eur NUMERIC(18,2) NOT NULL
|
|
);
|