Add event-sourced wallet and transaction tracking system
Wallets table with 7 seeded wallets, events table for three transaction types (bank_to_exchange, exchange_to_wallet, wallet_to_wallet). Balances computed from event credits/debits in sats. REST endpoints for CRUD. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE events (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
event_type TEXT NOT NULL,
|
||||
occurred_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
recorded_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
sats BIGINT,
|
||||
fee_sats BIGINT,
|
||||
fiat_amount NUMERIC(18,2),
|
||||
fiat_currency TEXT,
|
||||
from_wallet_id UUID REFERENCES wallets(id),
|
||||
to_wallet_id UUID REFERENCES wallets(id),
|
||||
note TEXT
|
||||
);
|
||||
--;;
|
||||
CREATE INDEX idx_events_type ON events (event_type);
|
||||
--;;
|
||||
CREATE INDEX idx_events_occurred ON events (occurred_at);
|
||||
Reference in New Issue
Block a user