db: apply good_jobs migrations

Apply a couple of migrations from `bin/rails generate good_job:update`.
This commit is contained in:
evazion
2022-10-26 03:55:59 -05:00
parent f90db34323
commit 33e9e5b3f0
3 changed files with 75 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
# frozen_string_literal: true
class CreateGoodJobSettings < ActiveRecord::Migration[7.0]
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

View File

@@ -0,0 +1,18 @@
# frozen_string_literal: true
class CreateIndexGoodJobsJobsOnPriorityCreatedAtWhenUnfinished < ActiveRecord::Migration[7.0]
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