Search code examples
phplaravelqueuejobsjob-batching

How to change Laravel's Job Batching table name and connection


Laravel 8 introduced Job Batching, which allows to execute jobs in batches and perform actions on batch completion. However Laravel documentation does not have a section regarding configurations of Job Batching table and database connection.

How can different database for job_batching table can be specified, and is it possible to rename the job_batching table name?


Solution

  • Open queue.php file in the config/ folder.

    You can specify custom database and table name by editing/adding the batching key:

    return [
        /* Default Queue Connection Name */
        'default' => env('QUEUE_CONNECTION', 'sync'),
        ...
    
        // ADD THIS SECTION
        'batching' => [
            'database' => '<custom_database>',
            'table' => '<custom_job_batching>',
        ],
    
        ...
    ];