-
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
Allow to pass table option signed for primary key #768
Conversation
Please check my fixes in tests, are they correct? The main idea is that table column that is used in FK must be unsigned as referenced table's pk is. |
Will these changes still allow me to create a signed primary key? I think the tests are now only looking for unsigned primary keys. |
@rquadling yes they allow. For example: // Default (unsigned)
$this->table('test')->addColumn('name', 'string')->create();
// Custom with signed PK
$this->table('test', ['signed' => true])->addColumn('name', 'string')->create(); I fixed existing tests because of changing default behavior, so I think we need additional tests with signed pk. |
@DimazzzZ The extra tests to make sure signed PK is still feasible. I'd be wary about changing the default though. Consider all those migrations out there already. Rolling them back and then forward again could lead to issues. Ones that come under the heading of "It used to work and we've not changed anything!". |
I understand your concerns about these changes but how many and how often developers make signed PK? Or even other ids? IMHO most of them using hacks like @twoixter's from #250 (thanks him btw). My position is "table auto increment pk must be unsigned" since I'll add more tests as soon as posible. |
Hi @DimazzzZ , couldn't agree more! +1, or better +1,000 to this PR. ;-) |
@@ -215,6 +215,7 @@ public function createTable(Table $table) | |||
$column = new Column(); | |||
$column->setName('id') | |||
->setType('integer') | |||
->setSigned(isset($options['signed']) ? $options['signed'] : false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This represents a backwards compatibility break as implemented. The way to do it without breaking BC would be to keep the current behavior (signed by default) and respect the signed
option to create unsigned PKs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way to do it without breaking BC would be to keep the current behavior (signed by default) and respect the signed option to create unsigned PKs.
I thought about it and that was a second option... On the one hand it breaks a backwards compatibility but on the other hand is signed
pk is right behavior or we just want to save backwards compatibility forever? We can inform users via changelog about new pk behavior as it was done with PHP 5.3 support, by the way nobody forbids to download an older version of Phinx.
Also we may add new property to phinx.yml like signed_pk: false
or something.
Let's discuss.
Minor patch upgrades must not break BC. This is important as people rely on the semantic version numbers.
So, at best, introduce this as a patch, but allow the user to configure their setup to use unsigned PK, but the default must be signed. |
@rquadling okay this is a good reason. I'll set it as May we set this behavior as default in the major 1.0 version? |
Added fix as a minor patch with Who can restart Scrutinizer task or just merge the PK? |
We have to wait for merges. Takes a while sometimes. |
Looks good to me. @robmorgan do you have any objections to this? |
Can you add this option to the docs? |
I was in hospital, sorry. The docs has been updated. |
Hope all is OK. |
@rquadling all is ok, thanks! Any updates on this PR? |
Still waiting for Rob. |
Version 0.6.x released but PR still opened... Should I re-create PR for 0.6.x branch? ( |
Hi. Please do. |
Is there any ETA on this patch? |
Or my goodness! For one line change more than 100 lines of testing. That is what I call testing obsession. Technologies are good, but sometimes they just overkill. @DimazzzZ thank you for this PR. Hope it gets accepted. |
I can accept this if the default is |
@robmorgan so I update for |
Any updates to this PR? |
any word here? |
Version 0.8 is now out and this is still open? Any ETA? |
I tweaked the docs a little bit. I was on the fence about renaming the |
Just new pull request for #658 made by @Serhioromano. Very useful feature.
Are additional tests required?