budgit/internal/db/migrations/00012_create_allocations_table.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

21 lines
636 B
SQL

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