Add income_category_id only after categories table exists

This commit is contained in:
Jan Bader 2021-12-11 22:08:08 +00:00
parent 208ffce968
commit 8b6a8c3697
2 changed files with 3 additions and 2 deletions

View File

@ -2,8 +2,7 @@
CREATE TABLE budgets ( CREATE TABLE budgets (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY, id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
name text NOT NULL, name text NOT NULL,
last_modification timestamp with time zone, last_modification timestamp with time zone
income_category_id uuid NOT NULL REFERENCES categories (id) DEFERRABLE
); );
-- +goose Down -- +goose Down

View File

@ -4,6 +4,8 @@ CREATE TABLE categories (
category_group_id uuid NOT NULL REFERENCES category_groups (id) ON DELETE CASCADE, category_group_id uuid NOT NULL REFERENCES category_groups (id) ON DELETE CASCADE,
name varchar(50) NOT NULL name varchar(50) NOT NULL
); );
ALTER TABLE budgets ADD COLUMN income_category_id uuid NOT NULL REFERENCES categories (id) DEFERRABLE;
-- +goose Down -- +goose Down
ALTER TABLE budgets DROP COLUMN income_category_id;
DROP TABLE categories; DROP TABLE categories;