diff --git a/database/migrations/2025_02_09_100000_add_certificate_error_fields_to_excellences_table.php b/database/migrations/2025_02_09_100000_add_certificate_error_fields_to_excellences_table.php index 5e9a7b776..e25c466f9 100644 --- a/database/migrations/2025_02_09_100000_add_certificate_error_fields_to_excellences_table.php +++ b/database/migrations/2025_02_09_100000_add_certificate_error_fields_to_excellences_table.php @@ -12,8 +12,12 @@ public function up(): void { Schema::table('excellences', function (Blueprint $table) { - $table->text('certificate_generation_error')->nullable()->after('certificate_url'); - $table->text('certificate_sent_error')->nullable()->after('notified_at'); + if (! Schema::hasColumn('excellences', 'certificate_generation_error')) { + $table->text('certificate_generation_error')->nullable()->after('certificate_url'); + } + if (! Schema::hasColumn('excellences', 'certificate_sent_error')) { + $table->text('certificate_sent_error')->nullable()->after('notified_at'); + } }); } @@ -23,7 +27,16 @@ public function up(): void public function down(): void { Schema::table('excellences', function (Blueprint $table) { - $table->dropColumn(['certificate_generation_error', 'certificate_sent_error']); + $cols = []; + if (Schema::hasColumn('excellences', 'certificate_generation_error')) { + $cols[] = 'certificate_generation_error'; + } + if (Schema::hasColumn('excellences', 'certificate_sent_error')) { + $cols[] = 'certificate_sent_error'; + } + if ($cols !== []) { + $table->dropColumn($cols); + } }); } };