Open Owumaro opened 5 years ago
I'm also facing the same issue using hair_trigger with Rails 6. Migrations are not getting generated.
@jainbasil Me too. I have taken to going to the Rails console and issuing a variant of @Owumaro's note above:
Zeitwerk::Loader.eager_load_all
Rails.application.load_tasks
Rake::Task['db:generate_trigger_migration'].invoke
It would be great for this gem to get a fix so I can go back to just using the rake task!
Related to https://github.com/rails/rails/issues/37006
Is this still an issue? Seems like a fix may have been merged to rails 6 stable here: https://github.com/rails/rails/commit/3285f3df7bc3a7a978428044b5458f1eed30b1a9
@jenseng Confirmed I can now generate migrations with the rake task in Rails 6.0.3.5, so I think you're right it's been fixed upstream.
When I run
rake db:generate_trigger_migration
for my Rails 6.0 app I get "Nothing to do" even if I added triggers to a model.This is tied to this issue : https://github.com/rails/rails/issues/37006
See https://github.com/ojab/hair_trigger/blob/rails-6/lib/hair_trigger.rb#L24 To get models, this gem runs
However it is not enough in Rails 6.0, you have to run
Zeitwerk::Loader.eager_load_all
to load all models before runningActiveRecord::Base.descendants
.Not sure if this gem should adapt itself or wait for a fix in Rails.