diff --git a/modules/system/database/migrations/2022_10_14_000027_Db_Jobs_FailedJobs_Update.php b/modules/system/database/migrations/2022_10_14_000027_Db_Jobs_FailedJobs_Update.php new file mode 100644 index 0000000000..aab3662dfa --- /dev/null +++ b/modules/system/database/migrations/2022_10_14_000027_Db_Jobs_FailedJobs_Update.php @@ -0,0 +1,44 @@ +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'); + } +};