<?php

use App\Http\CSVAptimapEntetesSlugConstants;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCsvDonneesClientTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(CARTOGRAPHIE::CSV_DONNEES_CLIENT, function (Blueprint $table) {
            $table->id();
            foreach (CSVAptimapEntetesSlugConstants::SLUG_APTIMAP as $header => $value){
                $table->string(strtolower($header))->nullable();
            }
            $table->unsignedInteger(CARTOGRAPHIE::STRUCTURE_ID);
            $table->foreign(CARTOGRAPHIE::STRUCTURE_ID)->references('id')->on('structures');
            $table->string(CARTOGRAPHIE::CHECKSUM)->unique();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(CARTOGRAPHIE::CSV_DONNEES_CLIENT);
    }
}
