sponser event issue
This commit is contained in:
parent
6360ce035a
commit
2c8fb9e757
@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
@ -12,7 +13,13 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
$table->foreignId('sponsor_id')->nullable()->constrained('sponsors')->onDelete('cascade');
|
||||
$table->unsignedBigInteger('sponsor_id')->nullable()->after('employer_id');
|
||||
|
||||
// Only add FK constraint on MySQL (SQLite in-memory DB used in tests
|
||||
// does not reliably support named foreign keys via constrained()).
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->foreign('sponsor_id')->references('id')->on('sponsors')->onDelete('cascade');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -22,7 +29,9 @@ public function up(): void
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('announcements', function (Blueprint $table) {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->dropForeign(['sponsor_id']);
|
||||
}
|
||||
$table->dropColumn('sponsor_id');
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user