运行php artisan migrate
迁移数据库时
我得到以下错误:
In Migrator.php line 448:
Class 'AddNewStatusFlagsToUsersTable' not found
这是我的迁移代码。
<?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');
});
}
}
文件名2022_10_05_184432_add_new_status_flags_to_users_table.php
我运行了这个命令:php artisan clear-compiled
php artisan optimize:clear
composer dump-autoload
php artisan optimize
但仍然没有任何工作。
如何解决Laravel的迁移问题?
1条答案
按热度按时间js5cn81o1#
将
class AddNewStatusFlagsToUsersTable extend Migration
更改为return new class extends migration
以使用匿名迁移: