Laravel 4 Migration Fehler - schafft zwei auto_increment-Primärschlüssel-Felder

Machte ich eine migration mit diesem setup:

$table->increments('id');
$table->integer('user_id', 10)->unsigned(); //this is meant to be used as a foreign key

Nachdem ich php artisan migrate gibt es einen Fehler:

[Exception]                                                                                                                                                                                 
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 `transactions` (`id` int unsigned not null auto_increment primary key, `user_id` int unsigned not null auto_increment primary key) default character set utf8 collate utf8_unicode_ci) (Bindings: array ())

Ich nicht angeben, user_id, um ein auto_increment primary key, aber Migration behandelt es als so.

Wie kann ich einen foreign key in Migrationen?

Schreibe einen Kommentar