Skip to content

Commit

Permalink
Fix latest migration not affecting GoodJob.migrated? (#1175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain authored Dec 11, 2023
1 parent d06ed8e commit 5e9fe23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions app/models/good_job/base_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ def error_event_migrated?
migration_pending_warning!
false
end

def cron_indices_migrated?
return true if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)

migration_pending_warning!
false
end
end

# The ActiveJob job class, as a string
Expand Down
2 changes: 1 addition & 1 deletion lib/good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def self.deprecator
def self.migrated?
# Always update with the most recent migration check
GoodJob::Execution.reset_column_information
GoodJob::Execution.error_event_migrated?
GoodJob::Execution.cron_indices_migrated?
end

ActiveSupport.run_load_hooks(:good_job, self)
Expand Down
4 changes: 2 additions & 2 deletions spec/generators/good_job/update_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
run_in_example_app 'rails db:migrate'
end

# Check that `GoodJob.pending_migrations?` is updated
# Check that `GoodJob.migrated?` is updated
expect(GoodJob.migrated?).to be true
quiet do
run_in_example_app 'rails db:rollback STEP=2'
run_in_example_app 'rails db:rollback'
expect(GoodJob.migrated?).to be false
run_in_example_app 'rails db:migrate'
end
Expand Down

0 comments on commit 5e9fe23

Please sign in to comment.