開始我有這樣的遷移:自動遞增列ID不從1
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?
https://stackoverflow.com/questions/8923114/how-to-reset-auto- increment-in-mysql laravel有一個遷移新鮮命令:https://laravel-news.com/migrate-fresh – mkaatman
migrate:fresh是Laravel 5.5。目前Laravel的穩定版本是5.4 – Brad
謝謝。我從來沒有想過直接用mysql命令做。 –