<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('article', function (Blueprint $table) {
            $table->boolean('art_publie')->default(false)->after('art_slug');
        });

        // Les articles déjà en base (créés avant ce champ) sont considérés publiés.
        DB::table('article')->update(['art_publie' => true]);
    }

    public function down(): void
    {
        Schema::table('article', function (Blueprint $table) {
            $table->dropColumn('art_publie');
        });
    }
};
