budgit/internal/db/migrations/00013_index_allocation_audit_logs.sql
juancwu 2dac136049
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m31s
feat: savings allocations
2026-05-04 03:19:36 +00:00

15 lines
550 B
SQL

-- +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