REQUIRED_COLUMN_HAS_NULLS
A migration would make a column required while rows of its table hold no value in it.
Cause
A migration would make a column required while rows of its table hold no value in it.
Before a migration runs, nextly migrate counts the rows each statement that makes a column NOT NULL would break: rows holding no value in it, or every row for a required column added without a default. Where an earlier statement of the same migration writes to that table, the count waits until that statement, so a migration that fills its own rows first is not refused. The Why line names each collection, Single, field group or table, the field or column, and how many rows are in the way; for a field group, each collection and Single whose rows those are.
Refused before its first statement, nothing of the migration was applied. On MySQL, a migration refused part-way (after a statement that wrote to the table) names the statements that ran before it: a schema change among them stayed applied, and the attempt is recorded as failed, never as applied.
Fix
Give those rows a value in an earlier statement of the migration, or keep the field optional, then run the command again. A field made required in the Schema Builder or by the development push can be given a value for those rows when you save it, unless the field is unique: one value would repeat in those rows, or match a value another row already holds, so give each row its own value first.
Example
✗ `20261103_101500_posts.sql` was refused before any of its statements ran, and nothing of it was applied.
Why: Collection 'posts': field 'subtitle' cannot become required while 2 rows hold no value in it. Give those rows a value first, or keep the field optional.
Next: Give those rows a value in an earlier statement of the migration, or keep the field optional, then run the command again.
Docs: https://nextlyhq.com/docs/cli/errors/required-column-has-nulls (REQUIRED_COLUMN_HAS_NULLS)