<?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::disableForeignKeyConstraints(); 
        Schema::create('etablissements', function (Blueprint $table) {
            $table->id();
            $table->string('libellear');
            $table->string('libellefr');

            $table->unsignedBigInteger('cycle_id');
            $table->foreign('cycle_id')->references('id')->on('cycles')
            ->constrained()
            ->onUpdate('restrict')
            ->onDelete('restrict');
            $table->unsignedBigInteger('commune_id');
            $table->foreign('commune_id')->references('id')->on('communes')
            ->constrained()
            ->onUpdate('restrict')
            ->onDelete('restrict');
            $table->string('code');
            $table->decimal('latitude', 10, 8)->nullable();
            $table->decimal('longitude', 11, 8)->nullable();
            $table->string('date_creation');
            $table->string('etat')->nullable();
            $table->string('directeur')->nullable();
            $table->string('localisation')->nullable();
            $table->string('contact')->nullable();
            $table->string('email')->nullable();
            $table->string('photo')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('etablissements');
    }
};
