good_job 3.30.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +22 -0
- data/app/charts/good_job/scheduled_by_queue_chart.rb +2 -2
- data/app/controllers/good_job/cron_entries_controller.rb +0 -8
- data/app/controllers/good_job/metrics_controller.rb +1 -1
- data/app/controllers/good_job/performance_controller.rb +19 -0
- data/app/filters/good_job/base_filter.rb +1 -1
- data/app/helpers/good_job/application_helper.rb +1 -0
- data/app/models/concerns/good_job/error_events.rb +2 -2
- data/app/models/concerns/good_job/filterable.rb +1 -1
- data/app/models/good_job/base_execution.rb +544 -50
- data/app/models/good_job/cron_entry.rb +0 -2
- data/app/models/good_job/discrete_execution.rb +1 -26
- data/app/models/good_job/execution.rb +3 -609
- data/app/models/good_job/job.rb +37 -116
- data/app/models/good_job/process.rb +7 -20
- data/app/views/good_job/batches/index.html.erb +11 -15
- data/app/views/good_job/jobs/_executions.erb +1 -1
- data/app/views/good_job/jobs/_table.erb +1 -1
- data/app/views/good_job/jobs/show.html.erb +1 -8
- data/app/views/good_job/performance/index.html.erb +43 -0
- data/app/views/good_job/shared/_navbar.erb +5 -0
- data/config/locales/de.yml +10 -2
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +10 -2
- data/config/locales/fr.yml +10 -2
- data/config/locales/it.yml +10 -2
- data/config/locales/ja.yml +10 -2
- data/config/locales/ko.yml +10 -2
- data/config/locales/nl.yml +10 -2
- data/config/locales/pt-BR.yml +10 -2
- data/config/locales/ru.yml +10 -2
- data/config/locales/tr.yml +10 -2
- data/config/locales/uk.yml +10 -2
- data/config/routes.rb +2 -0
- data/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb +65 -3
- data/lib/good_job/active_job_extensions/batches.rb +1 -1
- data/lib/good_job/active_job_extensions/concurrency.rb +10 -10
- data/lib/good_job/adapter.rb +13 -24
- data/lib/good_job/configuration.rb +5 -1
- data/lib/good_job/current_thread.rb +6 -6
- data/lib/good_job/job_performer.rb +2 -2
- data/lib/good_job/log_subscriber.rb +2 -10
- data/lib/good_job/notifier.rb +3 -3
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +22 -21
- metadata +18 -30
- data/lib/generators/good_job/templates/update/migrations/02_create_good_job_settings.rb.erb +0 -20
- data/lib/generators/good_job/templates/update/migrations/03_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb.erb +0 -19
- data/lib/generators/good_job/templates/update/migrations/04_create_good_job_batches.rb.erb +0 -35
- data/lib/generators/good_job/templates/update/migrations/05_create_good_job_executions.rb.erb +0 -33
- data/lib/generators/good_job/templates/update/migrations/06_create_good_jobs_error_event.rb.erb +0 -16
- data/lib/generators/good_job/templates/update/migrations/07_recreate_good_job_cron_indexes_with_conditional.rb.erb +0 -45
- data/lib/generators/good_job/templates/update/migrations/08_create_good_job_labels.rb.erb +0 -15
- data/lib/generators/good_job/templates/update/migrations/09_create_good_job_labels_index.rb.erb +0 -22
- data/lib/generators/good_job/templates/update/migrations/10_remove_good_job_active_id_index.rb.erb +0 -21
- data/lib/generators/good_job/templates/update/migrations/11_create_index_good_job_jobs_for_candidate_lookup.rb.erb +0 -19
- data/lib/generators/good_job/templates/update/migrations/12_create_good_job_execution_error_backtrace.rb.erb +0 -15
- data/lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb +0 -17
- data/lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb +0 -37
- data/lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb +0 -15
data/lib/good_job/notifier.rb
CHANGED
@@ -51,7 +51,7 @@ module GoodJob # :nodoc:
|
|
51
51
|
# Send a message via Postgres NOTIFY
|
52
52
|
# @param message [#to_json]
|
53
53
|
def self.notify(message)
|
54
|
-
connection = ::GoodJob::
|
54
|
+
connection = ::GoodJob::Job.connection
|
55
55
|
connection.exec_query <<~SQL.squish
|
56
56
|
NOTIFY #{CHANNEL}, #{connection.quote(message.to_json)}
|
57
57
|
SQL
|
@@ -251,8 +251,8 @@ module GoodJob # :nodoc:
|
|
251
251
|
|
252
252
|
def with_connection
|
253
253
|
Rails.application.executor.wrap do
|
254
|
-
self.connection = ::GoodJob::
|
255
|
-
::GoodJob::
|
254
|
+
self.connection = ::GoodJob::Job.connection_pool.checkout.tap do |conn|
|
255
|
+
::GoodJob::Job.connection_pool.remove(conn)
|
256
256
|
end
|
257
257
|
end
|
258
258
|
connection.execute("SET application_name = #{connection.quote(self.class.name)}")
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -58,7 +58,7 @@ module GoodJob
|
|
58
58
|
|
59
59
|
# @!attribute [rw] active_record_parent_class
|
60
60
|
# @!scope class
|
61
|
-
# The ActiveRecord parent class inherited by +GoodJob::
|
61
|
+
# The ActiveRecord parent class inherited by +GoodJob::Job+ (default: +ActiveRecord::Base+).
|
62
62
|
# Use this when using multiple databases or other custom ActiveRecord configuration.
|
63
63
|
# @return [ActiveRecord::Base]
|
64
64
|
# @example Change the base class:
|
@@ -133,6 +133,7 @@ module GoodJob
|
|
133
133
|
def self.configure_active_record(&block)
|
134
134
|
self._active_record_configuration = block
|
135
135
|
end
|
136
|
+
|
136
137
|
mattr_accessor :_active_record_configuration, default: nil
|
137
138
|
|
138
139
|
# Stop executing jobs.
|
@@ -208,7 +209,7 @@ module GoodJob
|
|
208
209
|
include_discarded = GoodJob.configuration.cleanup_discarded_jobs?
|
209
210
|
|
210
211
|
ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { older_than: older_than, timestamp: timestamp }) do |payload|
|
211
|
-
|
212
|
+
deleted_jobs_count = 0
|
212
213
|
deleted_batches_count = 0
|
213
214
|
deleted_discrete_executions_count = 0
|
214
215
|
|
@@ -218,31 +219,27 @@ module GoodJob
|
|
218
219
|
active_job_ids = jobs_query.pluck(:active_job_id)
|
219
220
|
break if active_job_ids.empty?
|
220
221
|
|
221
|
-
|
222
|
-
|
223
|
-
deleted_discrete_executions_count += deleted_discrete_executions
|
224
|
-
end
|
222
|
+
deleted_discrete_executions = GoodJob::DiscreteExecution.where(active_job_id: active_job_ids).delete_all
|
223
|
+
deleted_discrete_executions_count += deleted_discrete_executions
|
225
224
|
|
226
|
-
|
227
|
-
|
225
|
+
deleted_jobs = GoodJob::Job.where(active_job_id: active_job_ids).delete_all
|
226
|
+
deleted_jobs_count += deleted_jobs
|
228
227
|
end
|
229
228
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
break if deleted.zero?
|
229
|
+
batches_query = GoodJob::BatchRecord.finished_before(timestamp).limit(in_batches_of)
|
230
|
+
batches_query = batches_query.succeeded unless include_discarded
|
231
|
+
loop do
|
232
|
+
deleted = batches_query.delete_all
|
233
|
+
break if deleted.zero?
|
236
234
|
|
237
|
-
|
238
|
-
end
|
235
|
+
deleted_batches_count += deleted
|
239
236
|
end
|
240
237
|
|
241
238
|
payload[:destroyed_batches_count] = deleted_batches_count
|
242
239
|
payload[:destroyed_discrete_executions_count] = deleted_discrete_executions_count
|
243
|
-
payload[:
|
240
|
+
payload[:destroyed_jobs_count] = deleted_jobs_count
|
244
241
|
|
245
|
-
destroyed_records_count = deleted_batches_count + deleted_discrete_executions_count +
|
242
|
+
destroyed_records_count = deleted_batches_count + deleted_discrete_executions_count + deleted_jobs_count
|
246
243
|
payload[:destroyed_records_count] = destroyed_records_count
|
247
244
|
|
248
245
|
destroyed_records_count
|
@@ -269,6 +266,12 @@ module GoodJob
|
|
269
266
|
end
|
270
267
|
end
|
271
268
|
|
269
|
+
# Tests whether GoodJob can be safely upgraded to v4
|
270
|
+
# @return [Boolean]
|
271
|
+
def self.v4_ready?
|
272
|
+
GoodJob::Job.discrete_support? && GoodJob::Job.where(finished_at: nil).where(is_discrete: [nil, false]).none?
|
273
|
+
end
|
274
|
+
|
272
275
|
# Deprecator for providing deprecation warnings.
|
273
276
|
# @return [ActiveSupport::Deprecation]
|
274
277
|
def self.deprecator
|
@@ -285,9 +288,7 @@ module GoodJob
|
|
285
288
|
# For use in tests/CI to validate GoodJob is up-to-date.
|
286
289
|
# @return [Boolean]
|
287
290
|
def self.migrated?
|
288
|
-
|
289
|
-
GoodJob::DiscreteExecution.reset_column_information
|
290
|
-
GoodJob::DiscreteExecution.monotonic_duration_migrated?
|
291
|
+
true
|
291
292
|
end
|
292
293
|
|
293
294
|
ActiveSupport.run_load_hooks(:good_job, self)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: good_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -16,84 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.
|
19
|
+
version: 6.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.
|
26
|
+
version: 6.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 6.
|
33
|
+
version: 6.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 6.
|
40
|
+
version: 6.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: concurrent-ruby
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.3.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.3.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fugit
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.11.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.11.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: railties
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 6.
|
75
|
+
version: 6.1.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 6.
|
82
|
+
version: 6.1.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: thor
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 1.0.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 1.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: capybara
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- app/controllers/good_job/frontends_controller.rb
|
256
256
|
- app/controllers/good_job/jobs_controller.rb
|
257
257
|
- app/controllers/good_job/metrics_controller.rb
|
258
|
+
- app/controllers/good_job/performance_controller.rb
|
258
259
|
- app/controllers/good_job/processes_controller.rb
|
259
260
|
- app/filters/good_job/base_filter.rb
|
260
261
|
- app/filters/good_job/batches_filter.rb
|
@@ -306,6 +307,7 @@ files:
|
|
306
307
|
- app/views/good_job/jobs/_table.erb
|
307
308
|
- app/views/good_job/jobs/index.html.erb
|
308
309
|
- app/views/good_job/jobs/show.html.erb
|
310
|
+
- app/views/good_job/performance/index.html.erb
|
309
311
|
- app/views/good_job/processes/index.html.erb
|
310
312
|
- app/views/good_job/shared/_alert.erb
|
311
313
|
- app/views/good_job/shared/_chart.erb
|
@@ -349,20 +351,6 @@ files:
|
|
349
351
|
- lib/generators/good_job/install_generator.rb
|
350
352
|
- lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb
|
351
353
|
- lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb
|
352
|
-
- lib/generators/good_job/templates/update/migrations/02_create_good_job_settings.rb.erb
|
353
|
-
- lib/generators/good_job/templates/update/migrations/03_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb.erb
|
354
|
-
- lib/generators/good_job/templates/update/migrations/04_create_good_job_batches.rb.erb
|
355
|
-
- lib/generators/good_job/templates/update/migrations/05_create_good_job_executions.rb.erb
|
356
|
-
- lib/generators/good_job/templates/update/migrations/06_create_good_jobs_error_event.rb.erb
|
357
|
-
- lib/generators/good_job/templates/update/migrations/07_recreate_good_job_cron_indexes_with_conditional.rb.erb
|
358
|
-
- lib/generators/good_job/templates/update/migrations/08_create_good_job_labels.rb.erb
|
359
|
-
- lib/generators/good_job/templates/update/migrations/09_create_good_job_labels_index.rb.erb
|
360
|
-
- lib/generators/good_job/templates/update/migrations/10_remove_good_job_active_id_index.rb.erb
|
361
|
-
- lib/generators/good_job/templates/update/migrations/11_create_index_good_job_jobs_for_candidate_lookup.rb.erb
|
362
|
-
- lib/generators/good_job/templates/update/migrations/12_create_good_job_execution_error_backtrace.rb.erb
|
363
|
-
- lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb
|
364
|
-
- lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb
|
365
|
-
- lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb
|
366
354
|
- lib/generators/good_job/update_generator.rb
|
367
355
|
- lib/good_job.rb
|
368
356
|
- lib/good_job/active_job_extensions/batches.rb
|
@@ -428,14 +416,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
428
416
|
requirements:
|
429
417
|
- - ">="
|
430
418
|
- !ruby/object:Gem::Version
|
431
|
-
version:
|
419
|
+
version: 3.0.0
|
432
420
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
433
421
|
requirements:
|
434
422
|
- - ">="
|
435
423
|
- !ruby/object:Gem::Version
|
436
424
|
version: '0'
|
437
425
|
requirements: []
|
438
|
-
rubygems_version: 3.5.
|
426
|
+
rubygems_version: 3.5.14
|
439
427
|
signing_key:
|
440
428
|
specification_version: 4
|
441
429
|
summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobSettings < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.table_exists?(:good_job_settings)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
create_table :good_job_settings, id: :uuid do |t|
|
14
|
-
t.timestamps
|
15
|
-
t.text :key
|
16
|
-
t.jsonb :value
|
17
|
-
t.index :key, unique: true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateIndexGoodJobsJobsOnPriorityCreatedAtWhenUnfinished < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
disable_ddl_transaction!
|
5
|
-
|
6
|
-
def change
|
7
|
-
reversible do |dir|
|
8
|
-
dir.up do
|
9
|
-
# Ensure this incremental update migration is idempotent
|
10
|
-
# with monolithic install migration.
|
11
|
-
return if connection.index_name_exists?(:good_jobs, :index_good_jobs_jobs_on_priority_created_at_when_unfinished)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },
|
16
|
-
where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished,
|
17
|
-
algorithm: :concurrently
|
18
|
-
end
|
19
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobBatches < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.table_exists?(:good_job_batches)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
create_table :good_job_batches, id: :uuid do |t|
|
14
|
-
t.timestamps
|
15
|
-
t.text :description
|
16
|
-
t.jsonb :serialized_properties
|
17
|
-
t.text :on_finish
|
18
|
-
t.text :on_success
|
19
|
-
t.text :on_discard
|
20
|
-
t.text :callback_queue_name
|
21
|
-
t.integer :callback_priority
|
22
|
-
t.datetime :enqueued_at
|
23
|
-
t.datetime :discarded_at
|
24
|
-
t.datetime :finished_at
|
25
|
-
end
|
26
|
-
|
27
|
-
change_table :good_jobs do |t|
|
28
|
-
t.uuid :batch_id
|
29
|
-
t.uuid :batch_callback_id
|
30
|
-
|
31
|
-
t.index :batch_id, where: "batch_id IS NOT NULL"
|
32
|
-
t.index :batch_callback_id, where: "batch_callback_id IS NOT NULL"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/lib/generators/good_job/templates/update/migrations/05_create_good_job_executions.rb.erb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobExecutions < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.table_exists?(:good_job_executions)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
create_table :good_job_executions, id: :uuid do |t|
|
14
|
-
t.timestamps
|
15
|
-
|
16
|
-
t.uuid :active_job_id, null: false
|
17
|
-
t.text :job_class
|
18
|
-
t.text :queue_name
|
19
|
-
t.jsonb :serialized_params
|
20
|
-
t.datetime :scheduled_at
|
21
|
-
t.datetime :finished_at
|
22
|
-
t.text :error
|
23
|
-
|
24
|
-
t.index [:active_job_id, :created_at], name: :index_good_job_executions_on_active_job_id_and_created_at
|
25
|
-
end
|
26
|
-
|
27
|
-
change_table :good_jobs do |t|
|
28
|
-
t.boolean :is_discrete
|
29
|
-
t.integer :executions_count
|
30
|
-
t.text :job_class
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/generators/good_job/templates/update/migrations/06_create_good_jobs_error_event.rb.erb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobsErrorEvent < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.column_exists?(:good_jobs, :error_event)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
add_column :good_jobs, :error_event, :integer, limit: 2
|
14
|
-
add_column :good_job_executions, :error_event, :integer, limit: 2
|
15
|
-
end
|
16
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
disable_ddl_transaction!
|
5
|
-
|
6
|
-
def change
|
7
|
-
reversible do |dir|
|
8
|
-
dir.up do
|
9
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)
|
10
|
-
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)",
|
11
|
-
name: :index_good_jobs_on_cron_key_and_created_at_cond, algorithm: :concurrently
|
12
|
-
end
|
13
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)
|
14
|
-
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true,
|
15
|
-
name: :index_good_jobs_on_cron_key_and_cron_at_cond, algorithm: :concurrently
|
16
|
-
end
|
17
|
-
|
18
|
-
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)
|
19
|
-
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at
|
20
|
-
end
|
21
|
-
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)
|
22
|
-
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
dir.down do
|
27
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at)
|
28
|
-
add_index :good_jobs, [:cron_key, :created_at],
|
29
|
-
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently
|
30
|
-
end
|
31
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at)
|
32
|
-
add_index :good_jobs, [:cron_key, :cron_at], unique: true,
|
33
|
-
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently
|
34
|
-
end
|
35
|
-
|
36
|
-
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond)
|
37
|
-
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at_cond
|
38
|
-
end
|
39
|
-
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond)
|
40
|
-
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at_cond
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobLabels < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.column_exists?(:good_jobs, :labels)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
add_column :good_jobs, :labels, :text, array: true
|
14
|
-
end
|
15
|
-
end
|
data/lib/generators/good_job/templates/update/migrations/09_create_good_job_labels_index.rb.erb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobLabelsIndex < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
disable_ddl_transaction!
|
5
|
-
|
6
|
-
def change
|
7
|
-
reversible do |dir|
|
8
|
-
dir.up do
|
9
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)
|
10
|
-
add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)",
|
11
|
-
name: :index_good_jobs_on_labels, algorithm: :concurrently
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
dir.down do
|
16
|
-
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)
|
17
|
-
remove_index :good_jobs, name: :index_good_jobs_on_labels
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/generators/good_job/templates/update/migrations/10_remove_good_job_active_id_index.rb.erb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class RemoveGoodJobActiveIdIndex < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
disable_ddl_transaction!
|
5
|
-
|
6
|
-
def change
|
7
|
-
reversible do |dir|
|
8
|
-
dir.up do
|
9
|
-
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
|
10
|
-
remove_index :good_jobs, name: :index_good_jobs_on_active_job_id
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
dir.down do
|
15
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
|
16
|
-
add_index :good_jobs, :active_job_id, name: :index_good_jobs_on_active_job_id
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
disable_ddl_transaction!
|
5
|
-
|
6
|
-
def change
|
7
|
-
reversible do |dir|
|
8
|
-
dir.up do
|
9
|
-
# Ensure this incremental update migration is idempotent
|
10
|
-
# with monolithic install migration.
|
11
|
-
return if connection.index_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },
|
16
|
-
where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup,
|
17
|
-
algorithm: :concurrently
|
18
|
-
end
|
19
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobExecutionErrorBacktrace < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.column_exists?(:good_job_executions, :error_backtrace)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
add_column :good_job_executions, :error_backtrace, :text, array: true
|
14
|
-
end
|
15
|
-
end
|
data/lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class CreateGoodJobProcessLockIds < ActiveRecord::Migration<%= migration_version %>
|
3
|
-
def change
|
4
|
-
reversible do |dir|
|
5
|
-
dir.up do
|
6
|
-
# Ensure this incremental update migration is idempotent
|
7
|
-
# with monolithic install migration.
|
8
|
-
return if connection.column_exists?(:good_jobs, :locked_by_id)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
add_column :good_jobs, :locked_by_id, :uuid
|
13
|
-
add_column :good_jobs, :locked_at, :datetime
|
14
|
-
add_column :good_job_executions, :process_id, :uuid
|
15
|
-
add_column :good_job_processes, :lock_type, :integer, limit: 2
|
16
|
-
end
|
17
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
class CreateGoodJobProcessLockIndexes < ActiveRecord::Migration<%= migration_version %>
|
3
|
-
disable_ddl_transaction!
|
4
|
-
|
5
|
-
def change
|
6
|
-
reversible do |dir|
|
7
|
-
dir.up do
|
8
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked)
|
9
|
-
add_index :good_jobs, [:priority, :scheduled_at],
|
10
|
-
order: { priority: "ASC NULLS LAST", scheduled_at: :asc },
|
11
|
-
where: "finished_at IS NULL AND locked_by_id IS NULL",
|
12
|
-
name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked,
|
13
|
-
algorithm: :concurrently
|
14
|
-
end
|
15
|
-
|
16
|
-
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_locked_by_id)
|
17
|
-
add_index :good_jobs, :locked_by_id,
|
18
|
-
where: "locked_by_id IS NOT NULL",
|
19
|
-
name: :index_good_jobs_on_locked_by_id,
|
20
|
-
algorithm: :concurrently
|
21
|
-
end
|
22
|
-
|
23
|
-
unless connection.index_name_exists?(:good_job_executions, :index_good_job_executions_on_process_id_and_created_at)
|
24
|
-
add_index :good_job_executions, [:process_id, :created_at],
|
25
|
-
name: :index_good_job_executions_on_process_id_and_created_at,
|
26
|
-
algorithm: :concurrently
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
dir.down do
|
31
|
-
remove_index(:good_jobs, name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked) if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked)
|
32
|
-
remove_index(:good_jobs, name: :index_good_jobs_on_locked_by_id) if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_locked_by_id)
|
33
|
-
remove_index(:good_job_executions, name: :index_good_job_executions_on_process_id_and_created_at) if connection.index_name_exists?(:good_job_executions, :index_good_job_executions_on_process_id_and_created_at)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateGoodJobExecutionDuration < ActiveRecord::Migration<%= migration_version %>
|
4
|
-
def change
|
5
|
-
reversible do |dir|
|
6
|
-
dir.up do
|
7
|
-
# Ensure this incremental update migration is idempotent
|
8
|
-
# with monolithic install migration.
|
9
|
-
return if connection.column_exists?(:good_job_executions, :duration)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
add_column :good_job_executions, :duration, :interval
|
14
|
-
end
|
15
|
-
end
|