Lravel Migrate
创建一个migrate
php artisan make:migration merge_ecshop_and_xingqiu_user_table --table=ecs_users
编写数据库迁移语句
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MergeEcshopAndXingqiuUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->tinyInteger('grade_id')->default(0);
$table->dateTime('grade_updtime')->nullable();
$table->integer('grade_ref_objid')->nullable();
$table->integer('lvl1')->default(1);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('grade_id');
$table->dropColumn('grade_updtime');
$table->dropColumn('grade_ref_objid');
$table->dropColumn('lvl1');
});
}
}
执行迁移
php artisan migrate
回滚
此命令将回滚最后一次“迁移”的操作
php artisan migrate:rollback