1.进入项目根目录执行artisan命令生成migration文件,能够指定--table和--path参数,会在对应目录下生成migration文件。php
php artisan make:migration alter_table_his_decisions --table=his_decisions --path=database/migrations/ca/
2.在migration文件中的up方法中新增或者修改字段spa
/** * 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参数到目录级别code
php artisan migrate --path=database/migrations/ca/
ps:blog
一个很好用的参数来查看artisan命令能够跟哪些参数,好比想知道迁移命令后接的参数ci
php artisan migrate --help