Skip to content

Commit dc70c90

Browse files
authoredOct 20, 2022
Update jobs tables to support Laravel 9 (#730)
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.
1 parent a52b466 commit dc70c90

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Winter\Storm\Database\Schema\Blueprint;
4+
use Winter\Storm\Support\Str;
5+
6+
return new class extends \Winter\Storm\Database\Updates\Migration
7+
{
8+
public function up()
9+
{
10+
Schema::table($this->getTableName(), function (Blueprint $table) {
11+
$table->longText('payload')->change();
12+
});
13+
14+
Schema::table($this->getFailedTableName(), function (Blueprint $table) {
15+
$table->string('uuid')->nullable()->unique()->after('id');
16+
$table->longText('payload')->change();
17+
$table->longText('exception')->change();
18+
});
19+
20+
// Generate UUIDs for existing failed jobs
21+
DB::table($this->getFailedTableName())->whereNull('uuid')->cursor()->each(function ($job) {
22+
DB::table($this->getFailedTableName())
23+
->where('id', $job->id)
24+
->update(['uuid' => (string) Str::uuid()]);
25+
});
26+
}
27+
28+
public function down()
29+
{
30+
Schema::table($this->getFailedTableName(), function (Blueprint $table) {
31+
$table->dropColumn('uuid');
32+
});
33+
}
34+
35+
protected function getTableName()
36+
{
37+
return Config::get('queue.connections.database.table', 'jobs');
38+
}
39+
40+
protected function getFailedTableName()
41+
{
42+
return Config::get('queue.failed.table', 'failed_jobs');
43+
}
44+
};

0 commit comments

Comments
 (0)
Please sign in to comment.