auditionadmin/database/migrations/2024_05_29_043025_create_st...

34 lines
848 B
PHP

<?php
use App\Models\School;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('students', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(School::class)->constrained()->cascadeOnUpdate()->restrictOnDelete();
$table->string('first_name');
$table->string('last_name');
$table->integer('grade');
$table->timestamps();
$table->unique(['school_id','first_name','last_name']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('students');
}
};