-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add migrations before good job 4 bump
- Loading branch information
1 parent
ce2b0cc
commit 4c26913
Showing
15 changed files
with
340 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobSettings < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.table_exists?(:good_job_settings) | ||
end | ||
end | ||
|
||
create_table :good_job_settings, id: :uuid do |t| | ||
t.timestamps | ||
t.text :key | ||
t.jsonb :value | ||
t.index :key, unique: true | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
...rate/20241022100645_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateIndexGoodJobsJobsOnPriorityCreatedAtWhenUnfinished < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.index_name_exists?(:good_jobs, :index_good_jobs_jobs_on_priority_created_at_when_unfinished) | ||
end | ||
end | ||
|
||
add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc }, | ||
where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished, | ||
algorithm: :concurrently | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobBatches < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.table_exists?(:good_job_batches) | ||
end | ||
end | ||
|
||
create_table :good_job_batches, id: :uuid do |t| | ||
t.timestamps | ||
t.text :description | ||
t.jsonb :serialized_properties | ||
t.text :on_finish | ||
t.text :on_success | ||
t.text :on_discard | ||
t.text :callback_queue_name | ||
t.integer :callback_priority | ||
t.datetime :enqueued_at | ||
t.datetime :discarded_at | ||
t.datetime :finished_at | ||
end | ||
|
||
change_table :good_jobs do |t| | ||
t.uuid :batch_id | ||
t.uuid :batch_callback_id | ||
|
||
t.index :batch_id, where: "batch_id IS NOT NULL" | ||
t.index :batch_callback_id, where: "batch_callback_id IS NOT NULL" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobExecutions < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.table_exists?(:good_job_executions) | ||
end | ||
end | ||
|
||
create_table :good_job_executions, id: :uuid do |t| | ||
t.timestamps | ||
|
||
t.uuid :active_job_id, null: false | ||
t.text :job_class | ||
t.text :queue_name | ||
t.jsonb :serialized_params | ||
t.datetime :scheduled_at | ||
t.datetime :finished_at | ||
t.text :error | ||
|
||
t.index [:active_job_id, :created_at], name: :index_good_job_executions_on_active_job_id_and_created_at | ||
end | ||
|
||
change_table :good_jobs do |t| | ||
t.boolean :is_discrete | ||
t.integer :executions_count | ||
t.text :job_class | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobsErrorEvent < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.column_exists?(:good_jobs, :error_event) | ||
end | ||
end | ||
|
||
add_column :good_jobs, :error_event, :integer, limit: 2 | ||
add_column :good_job_executions, :error_event, :integer, limit: 2 | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
db/migrate/20241022100649_recreate_good_job_cron_indexes_with_conditional.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class RecreateGoodJobCronIndexesWithConditional < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond) | ||
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)", | ||
name: :index_good_jobs_on_cron_key_and_created_at_cond, algorithm: :concurrently | ||
end | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond) | ||
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true, | ||
name: :index_good_jobs_on_cron_key_and_cron_at_cond, algorithm: :concurrently | ||
end | ||
|
||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at | ||
end | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at | ||
end | ||
end | ||
|
||
dir.down do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at) | ||
add_index :good_jobs, [:cron_key, :created_at], | ||
name: :index_good_jobs_on_cron_key_and_created_at, algorithm: :concurrently | ||
end | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at) | ||
add_index :good_jobs, [:cron_key, :cron_at], unique: true, | ||
name: :index_good_jobs_on_cron_key_and_cron_at, algorithm: :concurrently | ||
end | ||
|
||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_created_at_cond) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_created_at_cond | ||
end | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_cron_key_and_cron_at_cond) | ||
remove_index :good_jobs, name: :index_good_jobs_on_cron_key_and_cron_at_cond | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobLabels < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.column_exists?(:good_jobs, :labels) | ||
end | ||
end | ||
|
||
add_column :good_jobs, :labels, :text, array: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels) | ||
add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)", | ||
name: :index_good_jobs_on_labels, algorithm: :concurrently | ||
end | ||
end | ||
|
||
dir.down do | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels) | ||
remove_index :good_jobs, name: :index_good_jobs_on_labels | ||
end | ||
end | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
db/migrate/20241022100652_remove_good_job_active_id_index.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoveGoodJobActiveIdIndex < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id) | ||
remove_index :good_jobs, name: :index_good_jobs_on_active_job_id | ||
end | ||
end | ||
|
||
dir.down do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id) | ||
add_index :good_jobs, :active_job_id, name: :index_good_jobs_on_active_job_id | ||
end | ||
end | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
db/migrate/20241022100653_create_index_good_job_jobs_for_candidate_lookup.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.index_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup) | ||
end | ||
end | ||
|
||
add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc }, | ||
where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup, | ||
algorithm: :concurrently | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
db/migrate/20241022100654_create_good_job_execution_error_backtrace.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobExecutionErrorBacktrace < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.column_exists?(:good_job_executions, :error_backtrace) | ||
end | ||
end | ||
|
||
add_column :good_job_executions, :error_backtrace, :text, array: true | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
db/migrate/20241022100655_create_good_job_process_lock_ids.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobProcessLockIds < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.column_exists?(:good_jobs, :locked_by_id) | ||
end | ||
end | ||
|
||
add_column :good_jobs, :locked_by_id, :uuid | ||
add_column :good_jobs, :locked_at, :datetime | ||
add_column :good_job_executions, :process_id, :uuid | ||
add_column :good_job_processes, :lock_type, :integer, limit: 2 | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
db/migrate/20241022100656_create_good_job_process_lock_indexes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobProcessLockIndexes < ActiveRecord::Migration[7.2] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
reversible do |dir| | ||
dir.up do | ||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked) | ||
add_index :good_jobs, [:priority, :scheduled_at], | ||
order: { priority: "ASC NULLS LAST", scheduled_at: :asc }, | ||
where: "finished_at IS NULL AND locked_by_id IS NULL", | ||
name: :index_good_jobs_on_priority_scheduled_at_unfinished_unlocked, | ||
algorithm: :concurrently | ||
end | ||
|
||
unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_locked_by_id) | ||
add_index :good_jobs, :locked_by_id, | ||
where: "locked_by_id IS NOT NULL", | ||
name: :index_good_jobs_on_locked_by_id, | ||
algorithm: :concurrently | ||
end | ||
|
||
unless connection.index_name_exists?(:good_job_executions, :index_good_job_executions_on_process_id_and_created_at) | ||
add_index :good_job_executions, [:process_id, :created_at], | ||
name: :index_good_job_executions_on_process_id_and_created_at, | ||
algorithm: :concurrently | ||
end | ||
end | ||
|
||
dir.down do | ||
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) | ||
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) | ||
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) | ||
end | ||
end | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
db/migrate/20241022100657_create_good_job_execution_duration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateGoodJobExecutionDuration < ActiveRecord::Migration[7.2] | ||
def change | ||
reversible do |dir| | ||
dir.up do | ||
# Ensure this incremental update migration is idempotent | ||
# with monolithic install migration. | ||
return if connection.column_exists?(:good_job_executions, :duration) | ||
end | ||
end | ||
|
||
add_column :good_job_executions, :duration, :interval | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.