Use a dummy-value at first and update it later. Deferrable doesn't seem to work for NOT NULL - only for FOREIGN KEYs.
12 lines
427 B
SQL
12 lines
427 B
SQL
-- +goose Up
|
|
CREATE TABLE categories (
|
|
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
|
|
category_group_id uuid NOT NULL REFERENCES category_groups (id) ON DELETE CASCADE,
|
|
name varchar(50) NOT NULL
|
|
);
|
|
ALTER TABLE budgets ADD COLUMN
|
|
income_category_id uuid NOT NULL REFERENCES categories (id) DEFERRABLE INITIALLY DEFERRED;
|
|
|
|
-- +goose Down
|
|
ALTER TABLE budgets DROP COLUMN income_category_id;
|
|
DROP TABLE categories; |