Skip to content

Commit 68a6952

Browse files
committed
Document caveat when deleting old migrations
1 parent 1f16768 commit 68a6952

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

guides/source/active_record_migrations.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,3 +1097,11 @@ If you run the `bin/rails db:migrate:status` command, which displays the status
10971097
(up or down) of each migration, you should see `********** NO FILE **********`
10981098
displayed next to any deleted migration file which was once executed on a
10991099
specific environment but can no longer be found in the `db/migrate/` directory.
1100+
1101+
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.
1102+
1103+
Thus, you generally want to preserve migrations coming from engines. They have a special comment like this:
1104+
1105+
```
1106+
# This migration comes from blorgh (originally 20210621082949)
1107+
```

0 commit comments

Comments
 (0)