You're reading docs for Nextly Alpha. APIs may change between releases.

CLIError codes

MIGRATION_NOT_WRITTEN

A migration file could not be moved into place once others of the same migration were there, so the command removed the files it had placed and wrote no migration.

Cause

A migration file could not be moved into place once others of the same migration were there, so the command removed the files it had placed and wrote no migration.

A command that writes a migration writes every file of it in full under a temporary name first: the migration, its snapshot, and the file of each translations table it changes. It then moves them to their names one after another. A move can still fail, for example where the folder stopped being writable in between. Left as they were, the files already moved would be part of a migration, and the next migrate:create would read it as a whole one and never write the rest.

So the command removes the files it had just placed, and only those, and stops. It does this only while it still holds the project's migration files (see MIGRATIONS_WRITER_BUSY); a run another overtook removes nothing and ends with MIGRATIONS_WRITER_OVERTAKEN.

Fix

  • Check that the migrations folder and its meta folder can be written to and that the disk has room, then run the command again. It writes the whole migration.
  • Where the message names files it could not remove, delete them yourself before running the command again: they are part of the migration that was not finished.
  • Where nextly migrate ran at that same moment, it applied a file this command then removed, and the next nextly migrate stops with MIGRATION_MISSING. Record each file it names with nextly migrate:resolve --removed <file>, then run this command again and nextly migrate. The database already holds that change, so nextly migrate records the new file as applied without running it, or stops with MIGRATION_NOT_PROVEN, which says what to check.

Example

✗ The migration was not written: moving 20261020_120000_001_create_localization_posts.sql into place failed (EACCES).
  Why:  The files already placed were removed; the folder is as it was.
  Next: Check that the migrations folder can be written to and has room, then run `migrate:create` again.
  Docs: https://nextlyhq.com/docs/cli/errors/migration-not-written  (MIGRATION_NOT_WRITTEN)

On this page

Was this page helpful?