Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Adds the necessary migrations

Marcello Rocha263de9abaa6f
diff --git a/db/migrate/20241202112406_create_good_job_execution_error_backtrace.rb b/db/migrate/20241202112406_create_good_job_execution_error_backtrace.rb
new file mode 100644
index 00000000000..6b054b64060
--- /dev/null
+++ b/db/migrate/20241202112406_create_good_job_execution_error_backtrace.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+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
+ end
+end
diff --git a/db/migrate/20241202112407_create_good_job_process_lock_ids.rb b/db/migrate/20241202112407_create_good_job_process_lock_ids.rb
new file mode 100644
index 00000000000..901fb607e95
--- /dev/null
+++ b/db/migrate/20241202112407_create_good_job_process_lock_ids.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+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
+
+ # rubocop:disable Rails/BulkChangeTable
+ 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
+ # rubocop:enable Rails/BulkChangeTable
+ end
+end
diff --git a/db/migrate/20241202112408_create_good_job_process_lock_indexes.rb b/db/migrate/20241202112408_create_good_job_process_lock_indexes.rb
new file mode 100644
index 00000000000..89fbe6e0036
--- /dev/null
+++ b/db/migrate/20241202112408_create_good_job_process_lock_indexes.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+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
+ end
+ # rubocop:enable Metrics/AbcSize
+end
diff --git a/db/migrate/20241202112409_create_good_job_execution_duration.rb b/db/migrate/20241202112409_create_good_job_execution_duration.rb
new file mode 100644
index 00000000000..fef37f07bc1
--- /dev/null
+++ b/db/migrate/20241202112409_create_good_job_execution_duration.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+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
+ end
+end