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