<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class ProjetTableauDonneesActionRse extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // On crée la table de paramétrage des unités d'oeuvre
        Schema::create('actions_unite_oeuvre', function (Blueprint $table) {
            $table->id();
            $table->string('libelle');
            $table->timestamps();
        });

        // On complète la table associative des actions d'un projet
        Schema::table('projets_actions_resp_soc_env', function($table) {
            $table->unsignedBigInteger('action_unite_oeuvre_id')->after('projet_id');
            $table->foreign('action_unite_oeuvre_id')->references('id')->on('actions_unite_oeuvre');
            $table->integer('cible')->nullable()->after('action_unite_oeuvre_id');
            $table->integer('notifie')->nullable()->after('cible');
            $table->integer('realise')->nullable()->after('notifie');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('actions_unite_oeuvre');
        Schema::table('projets_actions_resp_soc_env', function (Blueprint $table) {
            $table->dropColumn(['action_unite_oeuvre_id', 'cible', 'notifie', 'realise']);
        });
    }
}
