feat: savings allocations
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m31s

This commit is contained in:
juancwu 2026-05-04 03:19:36 +00:00
commit 2dac136049
17 changed files with 1140 additions and 4 deletions

View file

@ -0,0 +1,21 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE allocations (
id TEXT PRIMARY KEY NOT NULL,
account_id TEXT NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
name TEXT NOT NULL,
amount TEXT NOT NULL,
target_amount TEXT,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE (account_id, name)
);
CREATE INDEX idx_allocations_account_id ON allocations (account_id, sort_order);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE allocations;
-- +goose StatementEnd

View file

@ -0,0 +1,15 @@
-- +goose Up
-- +goose StatementBegin
-- Mirror of idx_space_audit_logs_account_id but for allocation.* actions, so
-- the account-scoped activity feed can OR-merge the two prefixes without a
-- sequential scan over space_audit_logs.
CREATE INDEX idx_space_audit_logs_allocation_account_id
ON space_audit_logs ((metadata->>'account_id'), created_at DESC)
WHERE action LIKE 'allocation.%';
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP INDEX IF EXISTS idx_space_audit_logs_allocation_account_id;
-- +goose StatementEnd