In this episode, we walk through how to set up Laravel queues to use a separate database from your application's main database. If you've used the database driver for Laravel queues, you probably know it drops queuing tables right in with everything else, which isn't always ideal, especially if you want to keep things tidy or improve performance a bit.
You'll see step-by-step how to duplicate your database configuration, set up new environment variables for your queue database, and update your config/queue.php
so that job and failed job tables end up in a totally separate database. There's a bit of migration tweaking as well — I'll show you the line you need to specify which connection your tables belong on (so migrations end up in the right place).
We create a test job together, run it, and check that both queued and failed jobs land in the new database. Plus, we'll briefly troubleshoot a common pitfall with failed jobs not being logged in the right place (hint: it's another config setting you might miss!). By the end, you'll have Laravel's database queues housecleaned into their own space — perfect if you're looking to keep your app database drama-free!