Import category

This commit is contained in:
2021-12-06 20:19:38 +00:00
parent 674028d394
commit 495bc2b7c3
7 changed files with 274 additions and 32 deletions

View File

@ -33,6 +33,7 @@ CREATE TABLE payees (
budget_id uuid NOT NULL,
name varchar(50) NOT NULL
);
ALTER TABLE "payees" ADD FOREIGN KEY ("budget_id") REFERENCES "budgets" ("id");
CREATE TABLE transactions (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
@ -40,10 +41,27 @@ CREATE TABLE transactions (
memo text NOT NULL,
amount decimal(12,2) NOT NULL,
account_id uuid NOT NULL,
category_id uuid,
payee_id uuid
);
ALTER TABLE "transactions" ADD FOREIGN KEY ("account_id") REFERENCES "accounts" ("id");
ALTER TABLE "transactions" ADD FOREIGN KEY ("payee_id") REFERENCES "payees" ("id");
ALTER TABLE "transactions" ADD FOREIGN KEY ("category_id") REFERENCES "categories" ("id");
CREATE TABLE category_groups (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
budget_id uuid NOT NULL,
name varchar(50) NOT NULL
);
ALTER TABLE "category_groups" ADD FOREIGN KEY ("budget_id") REFERENCES "budgets" ("id");
CREATE TABLE categories (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
category_group_id uuid NOT NULL,
name varchar(50) NOT NULL
);
ALTER TABLE "categories" ADD FOREIGN KEY ("category_group_id") REFERENCES "category_group" ("id");
-- +goose Down
DROP TABLE transactions;