UPDATE meta_subjects SET subject = 'invalid:subject.null' WHERE subject IS NULL; ALTER TABLE meta_subjects ALTER subject SET NOT NULL; ALTER TABLE meta_subjects ADD CONSTRAINT either_subject_or_redirect_not_null CHECK ( (subject IS NOT NULL AND redirect IS NULL) OR (subject IS NULL AND redirect IS NOT NULL) );