Catch DB errors

This commit is contained in:
James Cole
2023-04-07 19:33:19 +02:00
parent dd11f98be7
commit 79a4eec96e
26 changed files with 985 additions and 656 deletions

View File

@@ -22,6 +22,7 @@
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@@ -45,18 +46,28 @@ class FixNullables extends Migration
*/
public function up(): void
{
Schema::table(
'rule_groups',
static function (Blueprint $table) {
$table->text('description')->nullable()->change();
}
);
try {
Schema::table(
'rule_groups',
static function (Blueprint $table) {
$table->text('description')->nullable()->change();
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not update table: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
Schema::table(
'rules',
static function (Blueprint $table) {
$table->text('description')->nullable()->change();
}
);
try {
Schema::table(
'rules',
static function (Blueprint $table) {
$table->text('description')->nullable()->change();
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
}