customink / secondbase

Seamless second database integration for Rails.
MIT License
220 stars 31 forks source link

fix rake tasks for rails engine #62

Closed senid231 closed 5 years ago

senid231 commented 5 years ago

When you are developing rails engine which has connects with two databases you don't have ordinary rails tasks like db:migrate db:structure:load etc. They are moved into app namespace.

so instead of rake db:migrate you need to right rake app:db:migrate.

when you use gem with railtie that has rake tasks in rails engine those task namespaced into app too. Problem appears when you want to run another rake task inside of yours. For example when we inside app namespace we need to run app:db:migrate instead of `db:migrate.

in this PR I've solved this problem in a same way as active_record does - just call tasks using name related to current db namespace

metaskills commented 5 years ago

Oh neat, I've always loved this technique. Wanna covert it to a non-draft PR and let the tests run?

senid231 commented 5 years ago

@metaskills I've been thinking about adding tests for case when we have namespaced active_record tasks

senid231 commented 5 years ago

@metaskills looks like tests wasn't started automatically

metaskills commented 5 years ago

Interesting, I wonder if Draft PRs never trigger the tests? I'd say if this change just passes existing test, we are good.

senid231 commented 5 years ago

@metaskills draft PRs actually trigger tests in same way as normal PR does. Today I've added similar draft PR to parallel_tests and tests was started simultaneously.

metaskills commented 5 years ago

Agreed, but I think something might be odd in our /customink org. I heard from GitHub Enterprise support the other day about issues getting the Draft feature working correctly for us in both public and private repos. So assuming this is why I do not see a build triggered in TravisCI here https://travis-ci.org/customink/secondbase/pull_requests

Maybe create a new PR to test? No pun :)

senid231 commented 5 years ago

@metaskills looks like tests started when I add ordinary PR #63

senid231 commented 5 years ago

@metaskills but when I delete new PR ci jobs started to fail interesting behavior) I'll close this PR and move description to new one

senid231 commented 5 years ago

64