I'm trying to do some migrations, as I used to do in previous versions. but in this version of 5.8 I have an Error.
The error is of I'm trying to place the foreign keys
Example
Categories
Cat_Favorites
I have read the official documentation and what has been done as such. I have made a new project in 5.7 and everything works perfect. but with 5.8 no, I do not know if something has changed that I'm not realizing?
PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create tablethigsel.#sql-3356_2a(errno: 150 "Foreign key constraint is incorrectly formed")")
This error is not removed. but as I said if I do it in a version lower than 5.8 everything works fine.
Have you seen #27717?
I miss this information.
I just had to put in the foreign key
bigInteger
exactly how
BigIncrements
In my cross-reference, I mistakenly used bigInteger. I corrected with
$table->bigInteger('cliente_id')->unsigned();
Now works!
same of @antonioftamura i put the unsigned() method to work! if not doesn 麓t work for me.
Heres my code that its right:
Schema::create('places', function (Blueprint $table) {
$table->BigIncrements('id');
other file:
// place_id
$table->BigInteger('place_id')->unsigned();
$table->foreign('place_id')->references('id')->on('places');
Thanks!
Check that the storage engines for each table are the same as well. If they're different, it will throw this error
Most helpful comment
same of @antonioftamura i put the unsigned() method to work! if not doesn 麓t work for me.
Heres my code that its right:
Schema::create('places', function (Blueprint $table) { $table->BigIncrements('id');other file:
// place_id $table->BigInteger('place_id')->unsigned(); $table->foreign('place_id')->references('id')->on('places');Thanks!