Skip to content

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

@thisdotrob

Description

@thisdotrob

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions