git clone https://github.com/cviebrock/sequel-pro-laravel-export.git
.
然后進(jìn)入項(xiàng)目目錄劈伴,雙擊ExportToLaravelMigration.spBundle
文件窿侈,接下來(lái)在打開(kāi)的頁(yè)面連接到數(shù)據(jù)庫(kù)喇伯,在左側(cè)選中一張數(shù)據(jù)表艰争,在菜單欄選擇Bundles ? Export ? Export
將數(shù)據(jù)表導(dǎo)出為遷移文件(或者使用快捷命令???M
):
這樣就會(huì)將選中數(shù)據(jù)表轉(zhuǎn)化為 Laravel 數(shù)據(jù)庫(kù)遷移文件并存放在桌面熊经,
比如我選中的是users表德崭,對(duì)應(yīng)的遷移文件是2017_09_29_112221_create_users_table.php福铅,文件內(nèi)容如下:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Migration auto-generated by Sequel Pro Laravel Export
* @see https://github.com/cviebrock/sequel-pro-laravel-export
*/
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->integer('role_id')->nullable();
$table->string('name', 255);
$table->string('email', 255);
$table->string('avatar', 255)->nullable()->default('users/default.png');
$table->string('password', 255);
$table->rememberToken();
$table->nullableTimestamps();
$table->unique('email', 'users_email_unique');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
我們可以將其拷貝到 Laravel 項(xiàng)目的數(shù)據(jù)庫(kù)遷移目錄荔睹,以便后續(xù)使用該文件進(jìn)行后續(xù)操作狸演。