Skip to content

Commit

Permalink
Document caveat when deleting old migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Jun 21, 2021
1 parent 8929f6f commit e3e3a97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions guides/source/active_record_migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1097,3 +1097,11 @@ If you run the `bin/rails db:migrate:status` command, which displays the status
(up or down) of each migration, you should see `********** NO FILE **********`
displayed next to any deleted migration file which was once executed on a
specific environment but can no longer be found in the `db/migrate/` directory.

There's a caveat, though. Rake tasks to install migrations from engines are idempotent. Migrations present in the parent application due to a previous installation are skipped, and missing ones are copied with a new leading timestamp. If you deleted old engine migrations and ran the install task again, you'd get new files with new timestamps, and `db:migrate` would attempt to run them again.

Thus, you generally want to preserve migrations coming from engines. They have a special comment like this:

```
# This migration comes from blorgh (originally 20210621082949)
```

0 comments on commit e3e3a97

Please sign in to comment.