<?php

use App\Models\SecurityManagement\Role;
use App\Models\OrderManagement\OrderProduct;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(){
        Schema::whenTableDoesntHaveColumn((new Role)->getTable(),"editable",function (Blueprint $table){
            $table->boolean("editable")->default(true);
            $table->softDeletes();
        });
        Schema::whenTableDoesntHaveColumn((new Role)->getTable(),"deleted_at",function (Blueprint $table){
            $table->softDeletes();
        });
        Schema::whenTableDoesntHaveColumn((new Role)->getTable(),"created_by",function (Blueprint $table){
            $table->unsignedBigInteger("created_by")->nullable();
        });

        Schema::whenTableDoesntHaveColumn((new OrderProduct)->getTable(),"rejected",function (Blueprint $table){
            $table->boolean("rejected")->default(false)
                ->comment("Dtermine si le produit a été rejeté => Commande rejettée");
        });
    }

};
