Add available balance
This commit is contained in:
14
postgres/schema/202112072032_income-category.sql
Normal file
14
postgres/schema/202112072032_income-category.sql
Normal file
@ -0,0 +1,14 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE budgets ADD COLUMN income_category_id uuid NULL REFERENCES categories (id);
|
||||
UPDATE budgets
|
||||
SET income_category_id = (
|
||||
SELECT categories.id
|
||||
FROM categories
|
||||
LEFT JOIN category_groups ON category_groups.id = categories.category_group_id
|
||||
WHERE categories.name = 'Ready to Assign'
|
||||
AND category_groups.budget_id = budgets.id
|
||||
);
|
||||
ALTER TABLE budgets ALTER COLUMN income_category_id SET NOT NULL;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE budgets DROP COLUMN income_category_id;
|
Reference in New Issue
Block a user