我无法在 Laravel 中有数据的表中添加一列

我正在这样做:

创建:

php artisan make:migration add_total_invoice --table=invoices

代码:

public function up()
{
    Schema::table('invoices',function (Blueprint $table) {
        $table->double('total')->after('type');
    });
}

public function down()
{
    Schema::table('invoices',function (Blueprint $table) {
        $table->dropColumn('total');
    });
}
php artisan migrate

迁移运行没有问题,但是我要检查表并且没有添加列,如果我创建一个新的迁移并将总计放入新列,它说该列已经存在,是什么错误发生?

GY176984859 回答:我无法在 Laravel 中有数据的表中添加一列

转到数据库表并删除表中的前一个总计列,然后再次转到迁移表并删除最后一次迁移。然后再次运行php artisan migrate

本文链接:https://www.f2er.com/995.html

大家都在问