4

I am using Laravel Framework version Lumen (5.2.5). My requirement is to change jobs table name ( instead of jobs, I want uat_jobs in UAT and prod_jobs in PROD).

So as suggested in other StackOverflow anwer, changed table name in config\queue.php file but unable to create new job table. Getting error while runing php artisan queue:table command.

Thanks for the help in advance.

Jagadish
  • 61
  • 1
  • 3

2 Answers2

1

For dynamically change job table name use

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        if ('PROD' == $this->app->environment()) {
            Config::set('queue.connections.database.table', 'prod_jobs');
        } else if ('UAT' == $this->app->environment()) {
            Config::set('queue.connections.database.table', 'uat_jobs');
        }
    }
}
Davit Zeynalyan
  • 8,418
  • 5
  • 30
  • 55
0

Lumen doesn't have the queue:table command - that's for Laravel. You'll want to create the jobs table migration(s) manually. From the docs:

Schema::create('jobs', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('queue');
    $table->longText('payload');
    $table->tinyInteger('attempts')->unsigned();
    $table->tinyInteger('reserved')->unsigned();
    $table->unsignedInteger('reserved_at')->nullable();
    $table->unsignedInteger('available_at');
    $table->unsignedInteger('created_at');
    $table->index(['queue', 'reserved', 'reserved_at']);
});

Remember to rename the table in the above code to what you want.

Docs for your version: https://lumen.laravel.com/docs/5.2/queues - if you are not used to queues in Lumen, you'll want to read the rest in there as well.

Joel Hinz
  • 24,719
  • 6
  • 62
  • 75
  • Thank you very much for your answer. I have created the table manually with jobs schema So I have not tried your solution. – Jagadish Jul 03 '18 at 12:24