1.進入項目根目錄執行artisan命令生成migration文件,可以指定--table和--path參數,會在對應目錄下生成migration文件。
php artisan make:migration alter_table_his_decisions --table=his_decisions --path=database/migrations/ca/
2.在migration文件中的up方法中新增或者修改字段
/** * Run the migrations. * * @return void */ public function up() { Schema::table('his_decisions', function (Blueprint $table) { $table->string('primary_refuse_reason')->default('')->comment('拒絕主原因'); $table->string('secondary_refuse_reason')->default('')->comment('拒絕子原因'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('his_decisions', function (Blueprint $table) { $table->drop_column('primary_refuse_reason'); $table->drop_column('secondary_refuse_reason'); }); }
3.執行artisan命令來使變更生效,可以指定path參數到目錄級別
php artisan migrate --path=database/migrations/ca/
ps:
一個很好用的參數來查看artisan命令可以跟哪些參數,比如想知道遷移命令后接的參數
php artisan migrate --help