2016-05-20 13 views
0

のように定義する必要があります。移行の問題:一つだけのオート列、それは私が、次の移行持っキー

Schema::create('users', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->integer('level',5)->unsigned(); 
      $table->string('username',60); 
      $table->string('email')->unique(); 
      $table->string('password'); 
      $table->string('country',3); 
      $table->string('about',150); 
      $table->integer('balance')->unsigned(); 
      $table->string('photo_url'); 
      $table->string('photo_id',50); 
      $table->string('search_tag'); 

      $table->tinyInteger('is_bots'); 
      $table->rememberToken(); 
      $table->timestamps(); 
     }); 

それがスローエラー:

[PDOException]                                   
    SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key 

すべてが良いようだが、私は1つを持っていますラインが問題であることなど

答えて

4
$table->integer('level',5)->unsigned(); 

自動インクリメントであるプライマリキー。 integerの第2引数はサイズではありません。 2番目の引数は、(ブール)自動インクリメント用です。したがって、このフィールドに自動増分フィールドを指定しています。

Illuminate\Database\Schema\[email protected]

public function integer($column, $autoIncrement = false, $unsigned = false) 
関連する問題