【发布时间】:2015-01-25 09:11:07
【问题描述】:
我在下面创建了数据库迁移。我想做的是创建一个以 id 作为主键的帐户表。但是,我不希望密钥从 1 开始自动递增。相反,我希望它从 800500 开始自动递增。
有没有办法像这样设置主键的默认值?
我目前正在使用 Laravel v4.2.11 和 sqlite v3.8.3。
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAccountsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('accounts', function(Blueprint $table)
{
$table->increments('id')->unsigned()->default(800500);
$table->string('name', 100);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('accounts');
}
}
【问题讨论】: