Skip to content

Commit 1d30daf

Browse files
committed
FIX GoodJob deprecation warning
1 parent 3af81b1 commit 1d30daf

12 files changed

+262
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobSettings < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
class CreateIndexGoodJobsJobsOnPriorityCreatedAtWhenUnfinished < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobBatches < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobExecutions < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobsErrorEvent < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobLabels < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveGoodJobActiveIdIndex < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
class CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration[7.1]
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
class CreateGoodJobExecutionErrorBacktrace < ActiveRecord::Migration[7.1]
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

db/schema.rb

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)