這個是用php artisan指令的方法,使用make:migration,去建立生成一個在database/migrations底下的一支php
估計他是要用搬遷的時候,由這些的php去產生資料表、欄位的更動等等,而不是在phpmyadmin上的操作
所以具體的指令如下:
xx@xx:/test2/blog$ php artisan make:migration create_posts_table
Created Migration: 2019_03_28_034302_create_posts_table
這樣就建立好了
建立好後的檔案就是長這個樣子
database/migrations/2019_03_28_034302_create_posts_table.php
use IlluminateSupportFacadesSchema;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
}
想對外分享這則貼文嗎?運用網址更方便呦~