munak

마이그레이션 & DB 생성 시 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 에러 본문

SW 개발 언어/7. Laravel 5

마이그레이션 & DB 생성 시 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 에러

moonhak 2016. 3. 28. 18:06

마이그레이션을 통해 DB 테이블 생성하다가 아래와 같은 오류가 났다.


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


기존에 하던것과 달라진것은 글자수 제한이였다.

라라벨 코리아에서 번역한 문서를 보면 다음과 같다.(https://www.laravel.co.kr/docs/4.x/schema#creating-and-dropping-tables)

$table->string('email');VARCHAR 컬럼과 동일
$table->string('name', 100);길이가 지정된 VARCHAR 컬럼과 동일
$table->integer('votes');

테이블의 INTEGER와 동일

string은 위의 테이블에 정보가 나와있는데, integer은 안보여서 똑같이 했더니 에러가 난것이다.


해결 방법은 아래와 같다.

$table->integer('amount')->length(2);


Comments