ankane/multiverse

rails generate migration seems to ignore DB env

Closed this issue · 10 comments

Migrations generated using DB=other_db end up in db/migrate rather then db/other_db/migrate

Steps to reproduce:

  • rails generate multiverse:db other_db

  • DB=other_db rake db:create (optional)

  • DB=other_db rails generate migration create_foo

    • results in db/migrate/20180202083705_create_foo.rb rather than db/other_db/migrate/20180202083705_create_foo.rb
  • Environment: Rails 5.0.2, Mac OS X 10.12.6, GNU bash version 3.2.57

Hey @martinheld, maybe you need to restart spring? This functionality is covered in the tests.

@ankane thanks for your quick response. Unfortunately, spring restart didn't help. I had a brief look at the tests and found a TODO for asserting that the generated migrations end up in the right dir:

https://github.com/ankane/multiverse/blob/master/test/multiverse_test.rb#L69

Yeah, that's an additional test I want to add. You can see that it runs on the right database a few lines below:

assert_tables("catalog_development", ["products", "items"])

Ok, I ran the gem tests in my environment and everything works as expected, i.e., migration files in right directory. So I guess my rails setup is somewhat different and/or some other gems used in my project have a side effect here. I'll manually move the migrations files now and investigate later.

Just ran tests with Rails 5.0 patch versions and looks like it's an issue in versions before 5.0.3. I'll see if I can get it working when I have some time, or bump the min requirement to 5.0.3.

Thanks for the detailed report 👍

Should be fixed on master.

Running into this same issue, Rails 5.0.0.2, multiverse 0.2.0 with the latest patch.

Hey @justinperkins, there is no Rails 5.0.0.2.

Heh, oops I meant 5.0.0.1. Too many twos

Thanks for reporting. Fixed on master: 7131e39