> mobileapp Strategy - From Idea to Mobile App RealityVinova Our team will brainstorm with you on where to begin, where to go, and how to get you there. Whether you have a spark of an idea or an existing app – we can help. Getting your mobile strategy right is what our unique services are all about. We’ll wrestle with business challenges, discover new opportunities that will help you define and refine your product ideas into mobile app reality.

Be Careful: Laravel 5.8 Added bigIncrements As Defaults – Laravel Daily

Be Careful: Laravel 5.8 Added bigIncrements As Defaults – Laravel Daily

There is one change in Laravel 5.8 that is not mentioned in the official Upgrade Guide but caused me problems – I couldn’t create a foreign key migration, and spent half-hour until found out the reasons. So I want to share, maybe you will encounter the same thing.

My Situation Example and Error

While working on one project, I’ve created a simple table transaction_types:

And added just one new string() field:

And then tried to create a migration for transactions table with a foreign key, with same syntax I used to do all the time:

Migration file content:

And here’s what happened when running php artisan migrate:

As usual, the error “cannot add foreign key constraint” doesn’t give much details so I was just guessing, what could go wrong:

Look closer at what Laravel is generating when doing php artisan make:migration command:

bigIncrements. BIG increments. And then, of course, if you’re doing a foreign key from just “unsigned integer” type (as I always did my whole life), it fails. Type mismatch. Obviously.

How to Fix

Well, it’s easy. There are two ways to make it work:

The choice is yours.

Why Am I so Angry About It

Simple – this change wasn’t mentioned anywhere in 5.8 changes.

So, it makes me think that probably it’s only me with this problem, and everyone else will actually notice that migrations are being generated with bigIncrements().

After some googling, I’ve found one Reddit thread and one Stackoverflow post about it. That’s it.

Oh, and, of course, it was mentioned and discussed in the official Github repository of Laravel, back in November 2018:

Don’t get me wrong, I’m not against that change to bigIncrements(). I’m just angry about how it was (NOT) communicated. Probably only a bunch of people participating in internal Github communications actually knew about this change.

P.S. Oh, by the way, default users table migration also comes with bigIncrements():

So whenever you create new fields with foreign key to users, don’t forget to use bigInteger().

Like our articles?
Check out our Laravel online courses!

This content was originally published here.

Malcare WordPress Security

graphic designer in singapore,mobile application development singapore,website development singapore,web design singapore,singapore mobile application developer,singapore web development,app development singapore,design agency singapore,mobile app development singapore,web design company singapore,singapore app developer,singapore web design services,singapore website design,singapore web design,website developer singapore,web designer singapore,website design singapore,mobile apps singapore,website designer singapore,design firms in singapore,mobile game developer singapore,web application singapore,ios developer singapore,web development singapore,ruby on rails developer singapore,singapore mobile app developer,android developer singapore,web development company singapore,mobile apps development singapore,developer in singapore,developers in singapore,mobile application developer singapore,ios app development singapore,mobile developer singapore,web design services singapore,mobile app developer singapore,app developer singapore