生成migration文件
php artisan make:migration alter_xxx_table
修改migration文件
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('xxx', function (Blueprint $table) {
$table->string('a', 1000); //增加
$table->string('b', 100)->nullable()->change(); //修改
$table->renameColumn('c', 'd'); //重命名
$table->dropColumn(['e', 'f', 'g']);//刪除
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('xxx', function (Blueprint $table) {
$table->drop_column('a'); //增加
$table->string('b', 100)->change(); //修改
$table->renameColumn('d', 'c'); //重命名
$table->string('e', 1000); //刪除
$table->string('f', 1000); //刪除
$table->string('g', 1000); //刪除
});
}
執行命令
php artisan migrate
撤回命令
php artisan migrate:rollback --step=n(n爲撤回步數)