【发布时间】:2017-11-03 00:57:12
【问题描述】:
我有这个迁移:
public function up()
{
Schema::create('players', function (Blueprint $table) {
$table->increments('id');
$table->char('country_code',2);
$table->integer('unoi_id');
$table->string('first_name');
$table->string('last_name');
$table->char('gender', 1);
$table->timestamp('birthdate');
$table->integer('school_id');
$table->string('school_period');
$table->string('school_level');
$table->integer('points');
$table->timestamps();
});
Schema::table('players', function(Blueprint $table){
$table->foreign('country_code')->references('country_code')->on('countries');
});
}
当我创建一条新记录时,id 列中的值不是从 1 开始的。它从 321654 之类的东西开始,然后每次递增 1。
我的问题是:如何将默认值设置为 1?
【问题讨论】:
-
stackoverflow.com/questions/8923114/… laravel 有一个新迁移命令:laravel-news.com/migrate-fresh
-
migrate:fresh 是 Laravel 5.5。 Laravel 当前的稳定版本是 5.4
-
谢谢。我从没想过直接用mysql命令来做。
标签: php database laravel migration