mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Aggregate several new GoodJob migrations
This commit is contained in:
@@ -30,14 +30,7 @@
|
||||
|
||||
class CreateGoodJobExecutionErrorBacktrace < ActiveRecord::Migration[7.1]
|
||||
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
|
||||
# Moved to db/migrate/tables/good_job_executions.rb
|
||||
# These files are not squashed since good_job will recreate them otherwise when an update is done.
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,17 +30,7 @@
|
||||
|
||||
class CreateGoodJobProcessLockIds < ActiveRecord::Migration[7.1]
|
||||
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
|
||||
# Moved to several db/migrate/tables/good_job*.rb
|
||||
# These files are not squashed since good_job will recreate them otherwise when an update is done.
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,52 +29,8 @@
|
||||
#++
|
||||
|
||||
class CreateGoodJobProcessLockIndexes < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
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, %i[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, %i[process_id created_at],
|
||||
name: :index_good_job_executions_on_process_id_and_created_at,
|
||||
algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
|
||||
dir.down do
|
||||
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_priority_scheduled_at_unfinished_unlocked)
|
||||
end
|
||||
|
||||
if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_locked_by_id)
|
||||
remove_index(:good_jobs, name: :index_good_jobs_on_locked_by_id)
|
||||
end
|
||||
|
||||
if connection.index_name_exists?(
|
||||
:good_job_executions, :index_good_job_executions_on_process_id_and_created_at
|
||||
)
|
||||
remove_index(:good_job_executions, name: :index_good_job_executions_on_process_id_and_created_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
# Moved to several db/migrate/tables/good_job*.rb
|
||||
# These files are not squashed since good_job will recreate them otherwise when an update is done.
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
end
|
||||
|
||||
@@ -30,14 +30,7 @@
|
||||
|
||||
class CreateGoodJobExecutionDuration < ActiveRecord::Migration[7.1]
|
||||
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
|
||||
# Moved to db/migrate/tables/good_job_executions.rb
|
||||
# These files are not squashed since good_job will recreate them otherwise when an update is done.
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,9 +42,14 @@ class Tables::GoodJobExecutions < Tables::Base
|
||||
t.datetime :finished_at
|
||||
t.text :error
|
||||
t.integer :error_event, limit: 2
|
||||
t.text :error_backtrace, array: true
|
||||
t.uuid :process_id
|
||||
t.duration :interval
|
||||
|
||||
t.index %i[active_job_id created_at],
|
||||
name: :index_good_job_executions_on_active_job_id_and_created_at
|
||||
t.index %i[process_id created_at],
|
||||
name: :index_good_job_executions_on_process_id_and_created_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,6 +35,7 @@ class Tables::GoodJobProcesses < Tables::Base
|
||||
create_table migration, id: :uuid do |t|
|
||||
t.timestamps
|
||||
t.jsonb :state
|
||||
t.integer :lock_type, limit: 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,6 +53,8 @@ class Tables::GoodJobs < Tables::Base
|
||||
t.text :job_class
|
||||
t.integer :error_event, limit: 2
|
||||
t.text :labels, array: true
|
||||
t.uuid :locked_by_id
|
||||
t.datetime :locked_at
|
||||
|
||||
t.index :scheduled_at,
|
||||
where: "(finished_at IS NULL)",
|
||||
@@ -89,6 +91,13 @@ class Tables::GoodJobs < Tables::Base
|
||||
order: { priority: "ASC NULLS LAST", created_at: :asc },
|
||||
where: "finished_at IS NULL",
|
||||
name: :index_good_job_jobs_for_candidate_lookup
|
||||
t.index %i[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
|
||||
t.index :locked_by_id,
|
||||
where: "locked_by_id IS NOT NULL",
|
||||
name: :index_good_jobs_on_locked_by_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user