Laravel 迁移 - 删除列
2022-08-30 20:30:28
我需要从数据库表中删除该列。UserDomainName
clients
起初,我通过执行安装,然后执行 ,如文档中所述。doctrine/dbal
composer require doctrine/dbal
composer update
然后,我创建了要用于删除列的迁移:
php artisan make:migration remove_user_domain_name_from_clients --table=clients
我添加到该方法中:Schema::dropColumn('UserDomainName');
down()
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RemoveDomainName extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('clients', function (Blueprint $table) {
//
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('clients', function (Blueprint $table) {
Schema::dropColumn('UserDomainName');
});
}
}
但是,我得到
Migrating: 2017_08_22_135145_remove_user_domain_name_from_clients
Migrated: 2017_08_22_135145_remove_user_domain_name_from_clients
执行后,但不删除任何列。如果我再次执行它,我会得到php artisan migrate
Nothing to migrate.