BEGIN; ALTER TABLE inflections ALTER COLUMN index SET NOT NULL; ALTER TABLE inflections ADD CONSTRAINT index_is_not_negative CHECK (index >= 0); CREATE UNIQUE INDEX inflections_part_id_index ON inflections (part_id, index); COMMIT;