Skip to content

Commit 7d951b3

Browse files
committed
Migration to allow nesting batches
1 parent b8233fd commit 7d951b3

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

app/models/solid_queue/job_batch.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module SolidQueue
44
class JobBatch < Record
55
belongs_to :job, foreign_key: :job_id, optional: true
6+
belongs_to :parent_job_batch, foreign_key: :parent_job_batch_id, class_name: "SolidQueue::JobBatch", optional: true
67
has_many :jobs, foreign_key: :batch_id
78

89
serialize :on_finish_active_job, coder: JSON

db/migrate/20240131013203_create_solid_queue_batch_table.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class CreateSolidQueueBatchTable < ActiveRecord::Migration[7.1]
22
def change
33
create_table :solid_queue_job_batches do |t|
4+
t.references :parent_job_batch, index: true # FIXME: foreign key
45
t.text :on_finish_active_job
56
t.text :on_success_active_job
67
t.text :on_failure_active_job

test/dummy/db/schema.rb

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
end
4848

4949
create_table "solid_queue_job_batches", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
50+
t.bigint "parent_job_batch_id"
5051
t.text "on_finish_active_job"
5152
t.text "on_success_active_job"
5253
t.text "on_failure_active_job"
@@ -58,6 +59,7 @@
5859
t.index ["changed_at"], name: "index_solid_queue_job_batches_on_changed_at"
5960
t.index ["finished_at"], name: "index_solid_queue_job_batches_on_finished_at"
6061
t.index ["last_changed_at"], name: "index_solid_queue_job_batches_on_last_changed_at"
62+
t.index ["parent_job_batch_id"], name: "index_solid_queue_job_batches_on_parent_job_batch_id"
6163
end
6264

6365
create_table "solid_queue_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|

0 commit comments

Comments
 (0)