Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] use bigIncrements by default #4946

Merged
merged 1 commit into from Feb 25, 2019
Merged

Conversation

All new migrations will be using bigIncrements
laravel/framework#26472
@taylorotwell taylorotwell merged commit b681370 into laravel:develop Feb 25, 2019
1 check passed
1 check passed
continuous-integration/styleci/pr The analysis has passed
Details
realodix added a commit to realodix/urlhub that referenced this pull request Feb 27, 2019
@sebastienheyd

This comment has been minimized.

Copy link

@sebastienheyd sebastienheyd commented on 426df7a Mar 15, 2019

This needs to be documented here : https://laravel.com/docs/5.8/upgrade#upgrade-5.8.0

After updating from 5.7 this can result to an error if you use foreign_keys in your own migrations :

(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `role_user` add constraint `role_user_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade on update cascade)

This comment has been minimized.

Copy link
Contributor

@laurencei laurencei replied Mar 15, 2019

This comment has been minimized.

Copy link

@sebastienheyd sebastienheyd replied Mar 15, 2019

I have the case, I updated from 5.7 to 5.8 by following the upgrade guide in a WIP project.

By doing this all my packages have updated but not the migrations in the project's database folder.

The error happens when running php artisan migrate:fresh, packages "up to date migrations" have bigInteger but not the migrations in the project.

This comment has been minimized.

Copy link

@sebastienheyd sebastienheyd replied Mar 15, 2019

I fix it in the project folder, but I think that it's need to be documented.

This comment has been minimized.

Copy link
Member

@driesvints driesvints replied Mar 15, 2019

@sebastienheyd like @laurencei said, this only affects new migrations. It doesn't needs to be in the upgrade guide. It's in the changelog if you want to reference any changes to the skeleton.

This comment has been minimized.

Copy link

@techouse techouse replied Mar 16, 2019

IMO there should be an .env option to keep the legacy $table->increments('id'); inside new migration files generated by Artisan, because this can get annoying really quickly with foreign keys.

This comment has been minimized.

Copy link

@yusufkandemir yusufkandemir replied Apr 12, 2019

@laurencei and @driesvints, it looks like it is a breaking change as @sebastienheyd said. Changes on migration stubs is not breaking but a little change in create_users_table migration is breaking. It can break all packages that have migrations containing foreign keys to user_id. An example which shows causes of this change would be that issue.

This comment has been minimized.

Copy link
Contributor

@laurencei laurencei replied Apr 12, 2019

@yusufkandemir - its not breaking to an existing application. It is a change of behavior for new applications. But that's really the package incorrectly assuming it thought it knew what the user_id will always be, which is a mistake.

There has always been a chance the user_id might be a string (UUID) or a bigInt. There was never a guarantee in life that it would always be just an integer. If a package wants to force a foreign relationship onto a column it does not own, then it should be configurable. There's really no other option here, because regardless of defaults, the user table is outside of anyone's control except the developer doing it.

If someone runs into this, they can change their own user table to just use integer if they really want.

This comment has been minimized.

Copy link

@fulopattila122 fulopattila122 replied Apr 14, 2019

@laurencei

There was never a guarantee in life that it would always be just an integer

This is true, but it doesn't justify that the change isn't a BC.

BC is

A change in one part of a software system that potentially causes other components to fail.

Which applies here.

Nevertheless it's my turn to fix the package.

This comment has been minimized.

Copy link

@deleugpn deleugpn replied Apr 14, 2019

@fulopattila122 you can't claim BC break in the skeleton. This file could have been modified by any Laravel user at any moment and would have broken your package (for them) already. The change in the skeleton just made abundantly clear that hooking a foreign key into a database you don't own is setting yourself for broken apps.
Yes, you can try to argue that 99% of Laravel users don't change this file, but that's not a technical reference.
Any user at any moment can modify any Laravel skeleton file. You either hook yourself into the Laravel Framework or you make your package configurable to follow the user's skeleton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
You can’t perform that action at this time.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy