standalone-migrations icon indicating copy to clipboard operation
standalone-migrations copied to clipboard

move environment config into connection task

Open salzig opened this issue 6 years ago • 6 comments

move environment configuration into connection task, so it's not executed in situations where no standalone-migrations task is called. Allows other rake tasks to be executed when db/config.yml is missing. fixes #152

salzig avatar Feb 19 '19 13:02 salzig

would love to get some feedback on this proposed change. Maybe even suggestions how to get it working with older version of activerecord.

salzig avatar Feb 19 '19 13:02 salzig

Agreed, it's not ideal that the config is required even when the task isn't called. If anyone else using the project also has this need feel free to offer @salzig a hand or offer suggestions to try and come up with a general purpose approach for this.

thuss avatar Feb 19 '19 18:02 thuss

Hello @thuss @salzig . Can you merged the Pull Request ( @thuss )? I need the feature that fixes this issue.

I need the feature because I use Multiple database support and when I type a command bundle exec rake --tasks in the console, then I get the following error:

rake aborted!
Cannot load database configuration:
Could not load database configuration. No such file - ["db/config.yml"]
/home/cuurjol/ror/my_projects/sql_academy_activerecord/Rakefile:5:in `<top (required)>'
/home/cuurjol/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
/home/cuurjol/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'

Caused by:
Could not load database configuration. No such file - ["db/config.yml"]
/home/cuurjol/ror/my_projects/sql_academy_activerecord/Rakefile:5:in `<top (required)>'
/home/cuurjol/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
/home/cuurjol/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

cuurjol avatar May 03 '21 17:05 cuurjol

With this change the unit tests on Travis are failing with ActiveRecord 4.2.0 and 5.0.0 which is why this PR has never been merged. I think it's fine to say we don't support those older versions anymore but that will require changes in Gemfile, standalone_migrations.gemspec, and .travis.yml before we could merge this PR.

thuss avatar May 03 '21 22:05 thuss

just ran into the same issue!

jtoy avatar Aug 27 '22 20:08 jtoy

also why is the file path hardcoded? shouldnt it be configurable?

jtoy avatar Aug 27 '22 20:08 jtoy