Skip to content

Commit

Permalink
Update README instruction for engines path support (ilyakatz#346)
Browse files Browse the repository at this point in the history
* Update README instruction for engines path support

Since last version, support for Rails multi-engine setup has been included. However the README don't include instructions on how to configure it.

Additionally, we have never been able to make this feature work with the old "Rails Engines support" section instructions.

In this PR I propose to change this section for instructions on how to actually use the multiple `data_migrations_path` approach to get the same results with additional simplicity (you don't need to modify your engines initializers)

* Keep previous folder name
  • Loading branch information
gtrias authored and vprigent committed Nov 9, 2024
1 parent 7654e27 commit 2600c91
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,12 @@ From now on capistrano will run `rake db:migrate:with_data` in every deploy.
## Rails Engines support

This gem also has a initial support for adding data migrations inside Rails engines.
Inside the Engine's class initializer (the one that inherits from `Rails::Engine`, usually inside `engines/ENGINE_NAME/lib/engine.rb`) you need to add something like this:

Just add your engines directory pattern to data_migrations initializer, for example
in the case your engines are located in `engines` folder you can set it up like this:

```ruby
module EngineName
class Engine < ::Rails::Engine
initializer :engine_name do |app|
::DataMigrate.configure do |data_migrate|
default_path = ::DataMigrate::Config.new.data_migrations_path
data_migrate.data_migrations_path = [default_path, root.join('db', 'data')]
end
end
end
DataMigrate.configure do |config|
config.data_migrations_path = ['db/data'] + Dir['engines/**/db/data']
end
```

Expand Down

0 comments on commit 2600c91

Please sign in to comment.