From 7d951b3af7810a7421da231d63cda64daf352c6f Mon Sep 17 00:00:00 2001 From: JP Camara <48120+jpcamara@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:03:47 -0400 Subject: [PATCH] Migration to allow nesting batches --- app/models/solid_queue/job_batch.rb | 1 + db/migrate/20240131013203_create_solid_queue_batch_table.rb | 1 + test/dummy/db/schema.rb | 2 ++ 3 files changed, 4 insertions(+) diff --git a/app/models/solid_queue/job_batch.rb b/app/models/solid_queue/job_batch.rb index 1a94da03..61780f38 100644 --- a/app/models/solid_queue/job_batch.rb +++ b/app/models/solid_queue/job_batch.rb @@ -3,6 +3,7 @@ module SolidQueue class JobBatch < Record belongs_to :job, foreign_key: :job_id, optional: true + belongs_to :parent_job_batch, foreign_key: :parent_job_batch_id, class_name: "SolidQueue::JobBatch", optional: true has_many :jobs, foreign_key: :batch_id serialize :on_finish_active_job, coder: JSON diff --git a/db/migrate/20240131013203_create_solid_queue_batch_table.rb b/db/migrate/20240131013203_create_solid_queue_batch_table.rb index f97faee5..91b76ee8 100644 --- a/db/migrate/20240131013203_create_solid_queue_batch_table.rb +++ b/db/migrate/20240131013203_create_solid_queue_batch_table.rb @@ -1,6 +1,7 @@ class CreateSolidQueueBatchTable < ActiveRecord::Migration[7.1] def change create_table :solid_queue_job_batches do |t| + t.references :parent_job_batch, index: true # FIXME: foreign key t.text :on_finish_active_job t.text :on_success_active_job t.text :on_failure_active_job diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 294c5096..44a3fe46 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -47,6 +47,7 @@ end create_table "solid_queue_job_batches", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "parent_job_batch_id" t.text "on_finish_active_job" t.text "on_success_active_job" t.text "on_failure_active_job" @@ -58,6 +59,7 @@ t.index ["changed_at"], name: "index_solid_queue_job_batches_on_changed_at" t.index ["finished_at"], name: "index_solid_queue_job_batches_on_finished_at" t.index ["last_changed_at"], name: "index_solid_queue_job_batches_on_last_changed_at" + t.index ["parent_job_batch_id"], name: "index_solid_queue_job_batches_on_parent_job_batch_id" end create_table "solid_queue_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|