<?php

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

class AddFlaggedToCustomersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('customers') && Schema::hasColumn('customers', 'enable_feedback') && !Schema::hasColumn('customers', 'flagged')) {
            Schema::table('customers', function (Blueprint $table) {
                $table->boolean('flagged')->default(false)->after('enable_feedback');
            });
        }
        if (Schema::hasTable('clients') && Schema::hasColumn('clients', 'enable_feedback') && !Schema::hasColumn('clients', 'flagged')) {
            Schema::table('clients', function (Blueprint $table) {
                $table->boolean('flagged')->default(false)->after('enable_feedback');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // No-op: flagged column is part of base schema, do not drop
    }
}
