If you add a NOT NULL constraint to a column in a table that contains NULL entries, without a default value, the deployment will fail.
Rather than adding a default value, you can write a migration script to update all the existing NULL entries with a NOT NULL value before adding the NOT NULL constraint to the column:
Example: adding a NOT NULL constraint to a column
- Update
NULL entries with NOT NULL values. - Add the
NOT NULL constraint to the column.