LoginSignup
0
0

More than 3 years have passed since last update.

Laravelでマイグレ。$table->integer()の罠

Last updated at Posted at 2019-11-25

「わ〜!なんでやねんなんでやね〜ん」と私グレてます。

laravel6でmigrationカスタマイズ
            $table->integer('gender', 1);           // 性別:-1 ♂, 0, 1 ♀

ってやってました。そうしたらこう怒られるんです!

   Illuminate\Database\QueryException  : 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 (SQL: create table `pre_registers` (`id` bigint unsigned not null auto_increment primary key, `first_name` varchar(100) not null, ...

って。わけわからん。

もうどうしようもなくなって事務所を飛び出して、夜の街をぶらついたんです。でもやっぱり「戻ってググろう」って思い直して…

要するに結論は第2引数指定したらautoincrimentされるんだって。

参考記事

integerのサイズの指定方法に注意

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0