I'm trying to create multiple tables with foreign keys using Laravels migration. I have a problems migration table like so
Schema::create('problems', function($table)
{
$table->increments('id');
$table->integer('created_by')->unsigned();
$table->foreign('created_by')->references('id')->on('users');
$table->integer('category')->unsigned();
$table->foreign('category')->references('id')->on('categories');
$table->timestamps();
});
A categories migration
Schema::create('categories', function($table)
{
$table->increments('id');
$table->string('category_name');
$table->timestamps();
});
My first foreign key into the users migration works fine but as soon as it hits the foreign key for the category id, it gives a
SQLSTATE HY000 General Error 1215 Impossible d'ajouter des contraintes d'index externe (SQL; alter table 'problems' add constraint problems_category_foreign foreign key ('category') references 'categories' ('id'))
(I can't properly read the French and I don't know why it gives me errors in French. I have not been able to find a way to change it as I am not French, nor can I understand it)
I don't understand why this would work for one and not the other when they are essentially the same thing.