Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/rails db:reset marks a migration as run when it has not #138

Open
thisdotrob opened this issue Jan 13, 2023 · 0 comments
Open

bin/rails db:reset marks a migration as run when it has not #138

thisdotrob opened this issue Jan 13, 2023 · 0 comments

Comments

@thisdotrob
Copy link

I think I've encountered what might be a bug:

If I run bin/rails g lhm FooMigration it will add a new file e.g. db/lhm/20230113104049_foo_migration.rb

If I then run bin/rails db:reset I would expect this migration to be in the list of pending migrations in the output e.g.

You have 1 pending migration:
  20230113104049 FooMigration

But no pending migrations are listed.

If I then run bin/rails db:migrate the migration does not get run. Rails thinks it has already been run.

I've investigated a little and know that this is because when I run bin/rails db:reset, the migration's timestamp gets added to the schema_migrations table.

bin/rails db:migrate will only run migrations which do not have their timestamp in this table already.

I think the bug is that the migration's timestamp should not be added to schema_migrations on db:reset, it should be added only when the migration has run with db:migate.

If I put the LHM migration file in db/migrate instead of db/lhm the above issues are not seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant