-3

When I run php artisan migrate to migrate my database

I get the following error:

In Migrator.php line 448:

  Class 'AddNewStatusFlagsToUsersTable' not found

This is my code for my migration.

<?php

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

class AddNewStatusFlagsToUsersTable extends Migration
{
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->boolean('decline_plg')->default(false);
            $table->boolean('unresponsive')->default(false);
            $table->boolean('filing_directly_to_amazon')->default(false);
        });
    }

    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('decline_plg');
            $table->dropColumn('unresponsive');
            $table->dropColumn('filing_directly_to_amazon');
        });
    }
}

Filename 2022_10_05_184432_add_new_status_flags_to_users_table.php

I've run this commands:

php artisan clear-compiled

php artisan optimize:clear

composer dump-autoload

php artisan optimize

But still nothing works.

How to solve this laravel migration?

laurence keith albano
  • 1,409
  • 4
  • 27
  • 59

1 Answers1

0

change class AddNewStatusFlagsToUsersTable extend Migration to return new class extends migration to use Anonymous Migrations:

 <?php
    
    use Illuminate\Database\Migrations\Migration;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Support\Facades\Schema;
    
    return new class extends Migration
    {
        public function up()
        {
            Schema::table('users', function (Blueprint $table) {
                $table->boolean('decline_plg')->default(false);
                $table->boolean('unresponsive')->default(false);
                $table->boolean('filing_directly_to_amazon')->default(false);
            });
        }
    
        public function down()
        {
            Schema::table('users', function (Blueprint $table) {
                $table->dropColumn('decline_plg');
                $table->dropColumn('unresponsive');
                $table->dropColumn('filing_directly_to_amazon');
            });
        }
    }
AJ Zack
  • 205
  • 1
  • 8