ALTER TABLE finance.categories ADD CONSTRAINT uq_categories_space_name UNIQUE (space_id, name);