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

rake tasks for second_base does not load environment #59

Open
senid231 opened this issue Jul 12, 2018 · 3 comments
Open

rake tasks for second_base does not load environment #59

senid231 opened this issue Jul 12, 2018 · 3 comments

Comments

@senid231
Copy link

ActiveRecord task db:migrate loads environment and config
activerecord-5.1.4/lib/active_record/railties/databases.rake:56

desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
task migrate: [:environment, :load_config] do
  ActiveRecord::Tasks::DatabaseTasks.migrate
  db_namespace["_dump"].invoke
end

And SecondBase task db:second_base:migrate loads only config
secondbase-2.1.4/lib/second_base/databases.rake:30

task :migrate => ['db:load_config'] do
  SecondBase.on_base { Rake::Task['db:migrate'].execute }
end

as result I can't you classes/modules from app folder in migrations for second database

@senid231
Copy link
Author

senid231 commented Jul 12, 2018

it should be

task :migrate => ['db:load_config', :environment] do
  SecondBase.on_base { Rake::Task['db:migrate'].execute }
end

I tested this fix and it works fine

also I had another bug - after applying second_base:migrate I saw invalid inserts into schema_migrations in db/second_base/migrate/structure.sql (but second_base database schema_migrations had only correct data).

seems like this procees was broken after upgrading rake to 12.3.1

@workgena
Copy link

workgena commented Jul 12, 2018

Similar situation here #50
and some other commadns

@metaskills
Copy link
Member

Can someone open a PR to make that change? Would love to fix this and release a new version.

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

3 participants