-
Notifications
You must be signed in to change notification settings - Fork 892
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
BC break mitigation strategy #2154
Comments
I also ran into my migrations being 'broken' by this change. Tracking down where each foreign key was added to the schema and updating those migrations was pretty tedious. |
Seems that question was asked in the PR but was merged anyway. |
Yeah, there was no answer given at the time. I guess we need to revisit this, or provide a mitigation strategy as outlined above. |
Do you want to revert this change for now? It doesn't affect me, but does seem like a change we should make now if we're going to. |
It would be good to discuss mitigation strategies first, as this mainly affects us in terms of cake migration users right now. |
I don't think this should be reverted. In my opinion, Phinx (anad other DB migration libraries) should ideally encourage the best practice usage of a database, and having an unsigned primary key int is that, and is the recommendation in the official docs about auto-increment columns. There is some amount of split amongst other migration libraries here on what to do, e.g. rails uses signed while knex.js uses unsigned, so there's prior art to push for either direction and it works.
Both signed and unsigned foreign key columns are still valid, it just has to match what's allowed for the primary key. So we cannot have signed foreign key columns for unsigned primary keys since the allowed value ranges don't align, and the DB is (imo) smartly forbidding you from getting into a state where you can create stuff in your parent table that cannot be referenced in a child table.
Rails does this via versioning their base migration classes, where your migration can be
The migration strategy as outlined in the 0.13 release was to either:
I get that it's a painful thing to do, but it should be a one-off thing, and is probably just as painful as dealing with #1872. I feel like perhaps the biggest thing is having phinx get updated in a non-major version of cakephp/migrations given that since it's a shallow wrapper, it was majorly affected by a number of the BC breaks, not just on this one. |
I think that reverting cakephp/migrations#517 would make sense given the BC break this causes going from |
That would not solve the missing migration issue, though - and trigger a chain reacting of other things (also in terms of dependencies towards this). Not a perfect solution either way, I understand. |
If even reddit overflowed 32bit signed int only now I am not sure the grief this change caused was worth it. |
Should we also revert #1872 as that mostly certainly caused way more of a headache than this change, and I'll note wasn't called out in https://github.com/cakephp/migrations/releases/tag/3.7.0. |
Having it NULL by default shouldnt be creating that much of an issue? As they would be fine taking "not null" data? Could we maybe provide a "feature flag" for those and just deactivate this from Migrations plugin side unless actively enabled by user? |
Used to generate (typing this freehand):
It now generates:
While this probably won't "break" anyone's existing migrations in the way the signed change will, it does drastically affect the structure of data consistency. 0.13.0 was a very disruptive breaking change over a number of its PRs, and I think that downstream consumers that were shallowish wrappers bumping it in a minor release is probably not great in terms of semver. |
Again: The major version is not as important here as feature flags IMO to manage those defaults. If users and downstream tools are in power of those feature flags, they wouldnt have to deal with those any time soon, while any consumer that wants could go to the latest and coolest (e.g. for new projects). We would then:
|
That said: You could also do the other way around: |
Haven't had any issues reported for this change yet. We can reconsider if we do. Changing the pk/fk to unsigned was fine for phinx |
Can we agree on the feature flag to be quickly added and then disabled for current migrations release? |
Couldn't this be worked around by reintroducing the previous default in |
We could try that as quick solution for now, sure. |
As I said, the null change is probably not something that'll immediately bite people with an error message (unlike the PK signed change) unless they're inspecting the generated SQL and notice that it's now This change, like the signed PK change, should be called out in downstream wrappers, and not doing so is, in my opinion, setting your users up for unexpected issues down the road. |
PR open |
#1899
Since Phinx 0.13, foreign key columns have to be specified with
"signed" => false
Also refs cakephp/migrations#599
That causes now BC breaks in all kind of applications due to plugins not containing this
due to https://github.com/spryker/cakephp-statemachine/blob/81b6ca3c9fddf5dbacc8d863f4096f77a9d6c4c5/config/Migrations/20161029230233_StateMachineInit.php
Why was this a requirement again? Why couldnt we continue to treat also unsigned ones as valid foreign key columns and just use signed on by default then?
I would only expect the generation of new migration files to be "more specific", while keeping support for every file so far.
spryker/cakephp-statemachine@953489c seems to be needed, instead, maybe we could offer some migration to provide this where needed instead of just failing hard?
Not sure what could be done here.
The text was updated successfully, but these errors were encountered: