good_job 3.99.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -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/models/concerns/good_job/filterable.rb +1 -1
- data/app/models/good_job/base_execution.rb +104 -201
- data/app/models/good_job/cron_entry.rb +0 -2
- data/app/models/good_job/discrete_execution.rb +1 -31
- data/app/models/good_job/execution.rb +3 -7
- 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 +2 -2
- data/config/locales/de.yml +4 -7
- data/config/locales/en.yml +4 -7
- data/config/locales/es.yml +4 -7
- data/config/locales/fr.yml +4 -7
- data/config/locales/it.yml +4 -7
- data/config/locales/ja.yml +4 -7
- data/config/locales/ko.yml +4 -7
- data/config/locales/nl.yml +4 -7
- data/config/locales/pt-BR.yml +4 -7
- data/config/locales/ru.yml +4 -7
- data/config/locales/tr.yml +4 -7
- data/config/locales/uk.yml +4 -7
- data/config/routes.rb +1 -1
- 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 +16 -21
- metadata +18 -32
- data/app/controllers/good_job/performances_controller.rb +0 -23
- data/app/views/good_job/performances/show.html.erb +0 -50
- 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 -18
- data/lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb +0 -38
- data/lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb +0 -15
@@ -18,14 +18,6 @@ module GoodJob
|
|
18
18
|
# Responds to the +$0.good_job+ notification.
|
19
19
|
# @param event [ActiveSupport::Notifications::Event]
|
20
20
|
# @return [void]
|
21
|
-
def create(event)
|
22
|
-
# FIXME: This method does not match any good_job notifications.
|
23
|
-
execution = event.payload[:execution]
|
24
|
-
|
25
|
-
debug do
|
26
|
-
"GoodJob created job resource with id #{execution.id}"
|
27
|
-
end
|
28
|
-
end
|
29
21
|
|
30
22
|
# @!macro notification_responder
|
31
23
|
def finished_timer_task(event)
|
@@ -110,12 +102,12 @@ module GoodJob
|
|
110
102
|
|
111
103
|
# @!macro notification_responder
|
112
104
|
def perform_job(event)
|
113
|
-
|
105
|
+
job = event.payload[:job]
|
114
106
|
process_id = event.payload[:process_id]
|
115
107
|
thread_name = event.payload[:thread_name]
|
116
108
|
|
117
109
|
info(tags: [process_id, thread_name]) do
|
118
|
-
"Executed GoodJob #{
|
110
|
+
"Executed GoodJob #{job.id}"
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
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
|
@@ -291,9 +288,7 @@ module GoodJob
|
|
291
288
|
# For use in tests/CI to validate GoodJob is up-to-date.
|
292
289
|
# @return [Boolean]
|
293
290
|
def self.migrated?
|
294
|
-
|
295
|
-
GoodJob::DiscreteExecution.reset_column_information
|
296
|
-
GoodJob::DiscreteExecution.duration_interval_migrated?
|
291
|
+
true
|
297
292
|
end
|
298
293
|
|
299
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,7 +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/
|
258
|
+
- app/controllers/good_job/performance_controller.rb
|
259
259
|
- app/controllers/good_job/processes_controller.rb
|
260
260
|
- app/filters/good_job/base_filter.rb
|
261
261
|
- app/filters/good_job/batches_filter.rb
|
@@ -307,7 +307,7 @@ files:
|
|
307
307
|
- app/views/good_job/jobs/_table.erb
|
308
308
|
- app/views/good_job/jobs/index.html.erb
|
309
309
|
- app/views/good_job/jobs/show.html.erb
|
310
|
-
- app/views/good_job/
|
310
|
+
- app/views/good_job/performance/index.html.erb
|
311
311
|
- app/views/good_job/processes/index.html.erb
|
312
312
|
- app/views/good_job/shared/_alert.erb
|
313
313
|
- app/views/good_job/shared/_chart.erb
|
@@ -351,20 +351,6 @@ files:
|
|
351
351
|
- lib/generators/good_job/install_generator.rb
|
352
352
|
- lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb
|
353
353
|
- lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb
|
354
|
-
- lib/generators/good_job/templates/update/migrations/02_create_good_job_settings.rb.erb
|
355
|
-
- lib/generators/good_job/templates/update/migrations/03_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb.erb
|
356
|
-
- lib/generators/good_job/templates/update/migrations/04_create_good_job_batches.rb.erb
|
357
|
-
- lib/generators/good_job/templates/update/migrations/05_create_good_job_executions.rb.erb
|
358
|
-
- lib/generators/good_job/templates/update/migrations/06_create_good_jobs_error_event.rb.erb
|
359
|
-
- lib/generators/good_job/templates/update/migrations/07_recreate_good_job_cron_indexes_with_conditional.rb.erb
|
360
|
-
- lib/generators/good_job/templates/update/migrations/08_create_good_job_labels.rb.erb
|
361
|
-
- lib/generators/good_job/templates/update/migrations/09_create_good_job_labels_index.rb.erb
|
362
|
-
- lib/generators/good_job/templates/update/migrations/10_remove_good_job_active_id_index.rb.erb
|
363
|
-
- lib/generators/good_job/templates/update/migrations/11_create_index_good_job_jobs_for_candidate_lookup.rb.erb
|
364
|
-
- lib/generators/good_job/templates/update/migrations/12_create_good_job_execution_error_backtrace.rb.erb
|
365
|
-
- lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb
|
366
|
-
- lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb
|
367
|
-
- lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb
|
368
354
|
- lib/generators/good_job/update_generator.rb
|
369
355
|
- lib/good_job.rb
|
370
356
|
- lib/good_job/active_job_extensions/batches.rb
|
@@ -430,14 +416,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
430
416
|
requirements:
|
431
417
|
- - ">="
|
432
418
|
- !ruby/object:Gem::Version
|
433
|
-
version:
|
419
|
+
version: 3.0.0
|
434
420
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
435
421
|
requirements:
|
436
422
|
- - ">="
|
437
423
|
- !ruby/object:Gem::Version
|
438
424
|
version: '0'
|
439
425
|
requirements: []
|
440
|
-
rubygems_version: 3.5.
|
426
|
+
rubygems_version: 3.5.14
|
441
427
|
signing_key:
|
442
428
|
specification_version: 4
|
443
429
|
summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GoodJob
|
4
|
-
class PerformancesController < ApplicationController
|
5
|
-
def show
|
6
|
-
if GoodJob::DiscreteExecution.duration_interval_migrated?
|
7
|
-
@performances = GoodJob::DiscreteExecution
|
8
|
-
.where.not(job_class: nil)
|
9
|
-
.group(:job_class)
|
10
|
-
.select("
|
11
|
-
job_class,
|
12
|
-
COUNT(*) AS executions_count,
|
13
|
-
AVG(duration) AS avg_duration,
|
14
|
-
MIN(duration) AS min_duration,
|
15
|
-
MAX(duration) AS max_duration
|
16
|
-
")
|
17
|
-
.order("job_class")
|
18
|
-
else
|
19
|
-
@needs_upgrade = true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
<div class="border-bottom">
|
2
|
-
<h2 class="pt-3 pb-2"><%= t ".title" %></h2>
|
3
|
-
</div>
|
4
|
-
|
5
|
-
<% if @needs_upgrade %>
|
6
|
-
<div class="alert alert-warning">
|
7
|
-
<%= t "shared.needs_migration" %>
|
8
|
-
</div>
|
9
|
-
<% else %>
|
10
|
-
|
11
|
-
<div class="my-3 card">
|
12
|
-
<div class="list-group list-group-flush text-nowrap" role="table">
|
13
|
-
<header class="list-group-item bg-body-tertiary">
|
14
|
-
<div class="row small text-muted text-uppercase align-items-center">
|
15
|
-
<div class="col-12 col-lg-4"><%= t ".job_class" %></div>
|
16
|
-
<div class="col-lg-2 d-none d-lg-block"><%= t ".executions" %></div>
|
17
|
-
|
18
|
-
<div class="col-lg-2 d-none d-lg-block"><%= t ".average_duration" %></div>
|
19
|
-
<div class="col-lg-2 d-none d-lg-block"><%= t ".minimum_duration" %></div>
|
20
|
-
<div class="col-lg-2 d-none d-lg-block"><%= t ".maximum_duration" %></div>
|
21
|
-
</div>
|
22
|
-
</header>
|
23
|
-
|
24
|
-
<% @performances.each do |performance| %>
|
25
|
-
<div role="row" class="list-group-item py-3">
|
26
|
-
<div class="row align-items-center">
|
27
|
-
<div class="col-12 col-lg-4"><%= performance.job_class %></div>
|
28
|
-
<div class="col-6 col-lg-2 text-wrap">
|
29
|
-
<div class="d-lg-none small text-muted mt-1"><%= t ".executions" %></div>
|
30
|
-
<%= performance.executions_count %>
|
31
|
-
</div>
|
32
|
-
|
33
|
-
<div class="col-6 col-lg-2 text-wrap">
|
34
|
-
<div class="d-lg-none small text-muted mt-1"><%= t ".average_duration" %></div>
|
35
|
-
<%= format_duration performance.avg_duration %>
|
36
|
-
</div>
|
37
|
-
<div class="col-6 col-lg-2 text-wrap">
|
38
|
-
<div class="d-lg-none small text-muted mt-1"><%= t ".minimum_duration" %></div>
|
39
|
-
<%= format_duration performance.min_duration %>
|
40
|
-
</div>
|
41
|
-
<div class="col-6 col-lg-2 text-wrap">
|
42
|
-
<div class="d-lg-none small text-muted mt-1"><%= t ".maximum_duration" %></div>
|
43
|
-
<%= format_duration performance.max_duration %>
|
44
|
-
</div>
|
45
|
-
</div>
|
46
|
-
</div>
|
47
|
-
<% end %>
|
48
|
-
</div>
|
49
|
-
</div>
|
50
|
-
<% end %>
|
@@ -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
|