skip to Main Content

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 IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

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?

2

Answers


  1. I can’t see any obvious issues.

    Try running composer update

    Login or Signup to reply.
  2. change class AddNewStatusFlagsToUsersTable extend Migration to return new class extends migration to use Anonymous Migrations:

     <?php
        
        use IlluminateDatabaseMigrationsMigration;
        use IlluminateDatabaseSchemaBlueprint;
        use IlluminateSupportFacadesSchema;
        
        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');
                });
            }
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search