File: /var/www/api_matriculas/database/migrations/2025_09_30_185711_create_postulations_table.php
<?php
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('postulations', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('code_postulation')->nullable();
// 🔹 Estudiante
$table->string('student_first_name')->nullable();
$table->string('student_second_name')->nullable();
$table->string('student_last_name')->nullable();
$table->string('student_second_last_name')->nullable();
$table->string('student_rut', 20)->nullable();
$table->string('student_email')->nullable();
$table->string('student_mobile', 20)->nullable();
$table->date('student_birthdate')->nullable();
$table->unsignedBigInteger('student_gender_id')->nullable();
$table->unsignedBigInteger('student_country_id')->nullable();
$table->unsignedBigInteger('student_region_id')->nullable();
$table->unsignedBigInteger('student_commune_id')->nullable();
$table->string('student_address')->nullable();
// 🔹 Apoderado
$table->unsignedBigInteger('parent_relationship_id')->nullable();
$table->string('parent_first_name')->nullable();
$table->string('parent_second_name')->nullable();
$table->string('parent_last_name')->nullable();
$table->string('parent_second_last_name')->nullable();
$table->string('parent_rut', 20)->nullable();
$table->string('parent_email')->nullable();
$table->string('parent_mobile', 20)->nullable();
$table->unsignedBigInteger('parent_gender_id')->nullable();
$table->string('parent_profession')->nullable();
$table->unsignedBigInteger('parent_country_id')->nullable();
$table->unsignedBigInteger('parent_region_id')->nullable();
$table->unsignedBigInteger('parent_commune_id')->nullable();
$table->string('parent_address')->nullable();
// 🔹 Información académica
$table->unsignedBigInteger('course_id')->nullable();
$table->string('previous_school')->nullable();
$table->integer('siblings')->default(0);
$table->text('special_needs')->nullable();
$table->date('date_entry')->nullable();
// 🔹 Estado / control
$table->unsignedBigInteger('status_postulation_id')->nullable();
$table->unsignedBigInteger('period_id')->nullable();
$table->boolean('deleted')->default(false);
$table->boolean('status')->default(true);
$table->timestamps();
// 🔹 Auditoría
$table->unsignedBigInteger('user_created')->nullable();
$table->unsignedBigInteger('user_updated')->nullable();
// 🔹 Llaves foráneas
$table->foreign('student_gender_id')->references('id')->on('genders');
$table->foreign('student_country_id')->references('id')->on('countries');
$table->foreign('student_region_id')->references('id')->on('regions');
$table->foreign('student_commune_id')->references('id')->on('communes');
$table->foreign('parent_relationship_id')->references('id')->on('relationships');
$table->foreign('parent_gender_id')->references('id')->on('genders');
$table->foreign('parent_country_id')->references('id')->on('countries');
$table->foreign('parent_region_id')->references('id')->on('regions');
$table->foreign('parent_commune_id')->references('id')->on('communes');
$table->foreign('course_id')->references('id')->on('courses');
$table->foreign('status_postulation_id')->references('id')->on('status_postulation');
$table->foreign('period_id')->references('id')->on('periods');
});
}
public function down(): void
{
Schema::dropIfExists('postulations');
}
};