21 lines
636 B
SQL
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
|