update good_job

This commit is contained in:
Dylan Knutson
2023-08-18 18:15:31 -07:00
parent 5988152835
commit 401a730226
8 changed files with 145 additions and 6 deletions

View File

@@ -107,7 +107,7 @@ gem "discard"
gem "concurrent-ruby-ext", require: "concurrent"
gem "concurrent-ruby-edge", require: "concurrent-edge"
gem "pluck_each"
gem "good_job"
gem "good_job", "3.17.2"
gem "zstd-ruby"
gem "rszr"
gem "composite_primary_keys", "~> 14.0"

View File

@@ -141,14 +141,13 @@ GEM
raabro (~> 1.4)
globalid (1.1.0)
activesupport (>= 5.0)
good_job (3.14.2)
good_job (3.17.2)
activejob (>= 6.0.0)
activerecord (>= 6.0.0)
concurrent-ruby (>= 1.0.2)
fugit (>= 1.1)
railties (>= 6.0.0)
thor (>= 0.14.1)
webrick (>= 1.3)
google-protobuf (3.23.1)
htmlbeautifier (1.4.2)
http-cookie (1.0.5)
@@ -361,7 +360,6 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webrick (1.8.1)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
@@ -389,7 +387,7 @@ DEPENDENCIES
discard
disco
faiss
good_job
good_job (= 3.17.2)
htmlbeautifier
http-cookie
influxdb-client

View File

@@ -0,0 +1,20 @@
# 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,19 @@
# 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

View File

@@ -0,0 +1,35 @@
# frozen_string_literal: true
class CreateGoodJobBatches < 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_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

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
class CreateGoodJobExecutions < 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_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

View File

@@ -0,0 +1,16 @@
# frozen_string_literal: true
class CreateGoodJobsErrorEvent < 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.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

20
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_05_23_162724) do
ActiveRecord::Schema[7.0].define(version: 2023_08_19_011649) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
@@ -932,6 +932,20 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_23_162724) do
t.datetime "finished_at"
end
create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
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.integer "error_event", limit: 2
t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at"
end
create_table "good_job_processes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -963,6 +977,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_23_162724) do
t.datetime "cron_at"
t.uuid "batch_id"
t.uuid "batch_callback_id"
t.boolean "is_discrete"
t.integer "executions_count"
t.text "job_class"
t.integer "error_event", limit: 2
t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at"
t.index ["active_job_id"], name: "index_good_jobs_on_active_job_id"
t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)"