Skip to content

Commit

Permalink
Update jobs tables to support Laravel 9 (#730)
Browse files Browse the repository at this point in the history
Updates `failed_jobs` table to add missing `uuid` column. This also updates the `payload` and `exception` columns to be inline with the default Laravel migration.
  • Loading branch information
ericp-mrel committed Oct 20, 2022
1 parent 5a9df1e commit a0bb5b2
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

use Winter\Storm\Database\Schema\Blueprint;
use Winter\Storm\Support\Str;

return new class extends \Winter\Storm\Database\Updates\Migration
{
public function up()
{
Schema::table($this->getTableName(), function (Blueprint $table) {
$table->longText('payload')->change();
});

Schema::table($this->getFailedTableName(), function (Blueprint $table) {
$table->string('uuid')->nullable()->unique()->after('id');
$table->longText('payload')->change();
$table->longText('exception')->change();
});

// Generate UUIDs for existing failed jobs
DB::table($this->getFailedTableName())->whereNull('uuid')->cursor()->each(function ($job) {
DB::table($this->getFailedTableName())
->where('id', $job->id)
->update(['uuid' => (string) Str::uuid()]);
});
}

public function down()
{
Schema::table($this->getFailedTableName(), function (Blueprint $table) {
$table->dropColumn('uuid');
});
}

protected function getTableName()
{
return Config::get('queue.connections.database.table', 'jobs');
}

protected function getFailedTableName()
{
return Config::get('queue.failed.table', 'failed_jobs');
}
};

0 comments on commit a0bb5b2

Please sign in to comment.