-
Notifications
You must be signed in to change notification settings - Fork 194
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
Usage with Rails Engines #165
Comments
Hm, good question. I never really thought about it in terms of engines. The gem should really be used in whatever place has it's own database. So theoretically, it should work in an engine. Practically, I haven't tried it. Does it actually work? |
I added the following into each # Add seeds.rb to migrations
data_migrations_path = Array(::DataMigrate.config.data_migrations_path)
data_migrations_path << File.expand_path('db/data', config.root)
::DataMigrate.config.data_migrations_path = data_migrations_path
Was there initial work that never finished to support multiple paths? For example, you can find the following method # data_migrate/data_migrator_five.rb
def self.migrations_paths
[DataMigrate.config.data_migrations_path]
end |
I'm trying this as well, using the same technique as OP regarding migrations. I agree with @tleish that support for multiple paths will be needed, which will allow for a flow similar to what we do for migrations. The main app will need to load data_migrate, though, to get the rake tasks in the right place. Then if individual engines can add their data migrations to a path much like we do for schema migrations, I think everything should work nicely. @ilyakatz I'd be willing to do this work if it's interests you and you're willing to review it. |
Hi @kyrofa @ilyakatz and @tleish ! We're also looking to allow for many values of |
Oh sorry, looks like I missed the previous comment. And yes, I'm happy to take in a PR, I haven't been actively maintaining this (or working in Rails for that matter), so happy to merge incoming PRs |
Thanks @ilyakatz ... ya know, as it turns out, we're already able to pass multiple paths to the configuration! The value ends up being massed through to the |
Oh great, maybe one of the Rails upgrades made it possible. Do you mind updating Readme to indicate this, it may help other folks! |
Can do! We had some odd failures in CI related to this change so I'm just going to dig in and confirm it's related to our setup! Then I'll add to the README once I'm more confident other clients will be able to use the same approach 🙏 |
@alexevanczuk any updates on that? We are really looking forward to that 😄 |
@gustavodiel So we were able to get migrations to run locally with this:
However, on CI we had this error:
I think for our purposes, we are actually going to keep migrations in |
@alexevanczuk That seems to be an issue with initializer :engine 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 and worked flawlessly 😄 |
@gustavodiel so we've tried doing exactly what you did, and we get two problems
It also only read from one engine. We changed to ::DataMigrate.configure do |data_migrate|
new_path = root.join("db", "data")
current_path = ::DataMigrate.config.data_migrations_path
data_migrate.data_migrations_path = if current_path.instance_of?(Array)
current_path.concat([new_path])
else
[current_path, new_path]
end
end in each engine, which meant it picked up and ran migrations for each engine, but still doesn't work for creating the migration in the first place :/ |
Can some point me to best practice of using this gem with Rails engines, where each Rails Engine stores their own data migrations as they do with schema migrations? (see: https://blog.pivotal.io/labs/labs/leave-your-migrations-in-your-rails-engines)
The text was updated successfully, but these errors were encountered: