58 lines
2.3 KiB
PHP
58 lines
2.3 KiB
PHP
<?php
|
|
|
|
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->string('student_number', 30)->nullable()->unique();
|
|
$table->string('nisn', 30)->nullable()->unique();
|
|
$table->string('full_name', 150);
|
|
$table->enum('gender', ['L', 'P']);
|
|
$table->string('place_of_birth', 100)->nullable();
|
|
$table->date('date_of_birth')->nullable();
|
|
$table->string('religion', 50)->nullable();
|
|
$table->string('nationality', 50)->default('Indonesia');
|
|
$table->string('family_card_number', 30)->nullable();
|
|
$table->unsignedTinyInteger('child_order')->nullable();
|
|
$table->unsignedTinyInteger('number_of_siblings')->nullable();
|
|
$table->string('phone_number', 30)->nullable();
|
|
$table->string('email', 100)->nullable();
|
|
$table->text('address')->nullable();
|
|
$table->string('village', 100)->nullable();
|
|
$table->string('district', 100)->nullable();
|
|
$table->string('city', 100)->nullable();
|
|
$table->string('province', 100)->nullable();
|
|
$table->string('postal_code', 10)->nullable();
|
|
$table->foreignId('academic_year_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
|
$table->foreignId('department_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
|
$table->foreignId('class_id')->constrained('classes')->cascadeOnUpdate()->restrictOnDelete();
|
|
$table->date('entry_date')->nullable();
|
|
$table->enum('status', ['active', 'graduated', 'transferred', 'dropped', 'inactive'])->default('active');
|
|
$table->string('photo_path')->nullable();
|
|
$table->text('notes')->nullable();
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->index(['academic_year_id', 'department_id', 'class_id']);
|
|
$table->index('status');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('students');
|
|
}
|
|
};
|