ho fatto una migrazione con questa configurazione:laravel errore 4 Migrazione - crea due chiavi primarie AUTO_INCREMENT campi
$table->increments('id');
$table->integer('user_id', 10)->unsigned(); // this is meant to be used as a foreign key
Dopo aver fatto php artigianale migrare restituisce un errore:
[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())
non l'ho fatto specificare user_id per essere una chiave primaria auto_increment, ma la migrazione lo considera come tale.
Come posso creare una chiave esterna in Migrazioni?
Quindi come si gestiscono le chiavi esterne? – jrenouard
nvm, trova la risposta qui http://stackoverflow.com/questions/22077573/laravel-migration-will-not-add-foreign-key dovresti usare $ table-> intero ('app_group_id') -> length (10) -> senza segno(); in Laravel 4 – jrenouard