<?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::table('alunos', function (Blueprint $table) {

            $table->foreignId('user_id')
                ->nullable()
                ->after('id_turma')
                ->constrained('users')
                ->nullOnDelete();

            $table->foreignId('responsavel_user_id')
                ->nullable()
                ->after('user_id')
                ->constrained('users')
                ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('alunos', function (Blueprint $table) {
            $table->dropConstrainedForeignId('responsavel_user_id');
            $table->dropConstrainedForeignId('user_id');
        });
    }
};
