I'd like rake db:schema:load
to use a db/schema.rb
that's not located in my app, but in one of my gems. This already works for db:seed
by putting config.paths['db/seeds'] = Core::Engine.paths['db/seeds'].existent
in my application.rb
. (Core is a gem that's also a Rails engine).
However, there is no db/schema.rb
path in config.paths
and config.paths['db'] = Core::Engine.paths['db'].existent
has no effect.
What's the easiest way to get this done?
For anyone who stumbles upon this, as of Rails 4.0 you can set the 'db' key in your engine configuration and the main app will look for your schema there.
active_record/railties/databases.rake
module MyEngine
class Engine < ::Rails::Engine
initializer :override_db_dir do |app|
app.config.paths["db"] = config.paths['db'].expanded
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With