Laravel-4-Generators icon indicating copy to clipboard operation
Laravel-4-Generators copied to clipboard

Adding a column - generator tries to make it an auto-incrementing key

Open redknitin opened this issue 9 years ago • 1 comments

I tried to add a column to a table, but it seems to want to make the column a primary key which is why it fails. The commands I ran are: php artisan generate:migration add_account_id_to_transactions_table --fields="account_id:integer(11)" php artisan migrate

The errors displayed are the following

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table def inition; there can be only one auto column and it must be defined as a key (SQL: alter table transactions add account_id int not null auto_increme nt primary key)

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

redknitin avatar Oct 05 '14 13:10 redknitin

What is the type in the migration file? If it is defined as integer and not as increments, it's a Laravel issue, not a generator one.

mfutselaar avatar Oct 18 '14 19:10 mfutselaar