生成migration檔案
1 php artisan make:migration alter_xxx_table
修改migration檔案
1 public function up() 2 { 3 Schema::table('xxx', function (Blueprint $table) { 4 $table->string('a', 1000); //增加 5 $table->string('b', 100)->nullable()->change(); //修改 6 $table->renameColumn('c', 'd'); //重命名 7 $table->dropColumn(['e', 'f', 'g']);//洗掉 8 }); 9 } 10 11 /** 12 * Reverse the migrations. 13 * 14 * @return void 15 */ 16 public function down() 17 { 18 Schema::table('xxx', function (Blueprint $table) { 19 $table->drop_column('a'); //增加 20 $table->string('b', 100)->change(); //修改 21 $table->renameColumn('d', 'c'); //重命名 22 $table->string('e', 1000); //洗掉 23 $table->string('f', 1000); //洗掉 24 $table->string('g', 1000); //洗掉 25 }); 26 } 27 }
執行命令
1 php artisan migrate
撤回命令
1 php artisan migrate:rollback --step=n(n為撤回步數)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/20916.html
標籤:PHP
上一篇:深入 Laravel 內核之 PHP 反射機制和依賴注入
下一篇:PHP丨PHP基礎知識之資料型別
