creat new table
php artisan make:migration creat_xxx_table
到 database\migrations 找到該檔案打開編輯
add field
php artisan make:migration add_field_xxx_table
到 database\migrations 找到該檔案打開編輯
php artisan make:migration creat_xxx_table
到 database\migrations 找到該檔案打開編輯
public function up() { Schema::create('xxx', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); }); } public function down() { Schema::drop('xxx'); }
add field
php artisan make:migration add_field_xxx_table
到 database\migrations 找到該檔案打開編輯
public function up() { // Schema::table('xxx', function (Blueprint $table) { $table->string('id'); }); } public function down() { // Schema::table('xxx', function (Blueprint $table) { $table->dropColumn('id'); }); }以上編輯完存檔後執行 php artisan migrate 即可。
留言
張貼留言