28 lines
730 B
PHP
28 lines
730 B
PHP
<?php
|
|
|
|
use App\Models\Study;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('study_assignments', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignIdFor(Study::class)->constrained()->cascadeOnDelete();
|
|
$table->foreignIdFor(User::class)->nullable()->constrained()->nullOnDelete();
|
|
$table->timestamps();
|
|
|
|
$table->unique(['study_id', 'user_id']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('study_assignments');
|
|
}
|
|
};
|