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
Add support for specifying a nullable field #203
Comments
What about
|
What about text fields? They don't have a length, so a dumb user might do:
And we would maybe not have any idea what they are talking about. |
It might be doable with a sophisticated enough regex. |
Something like this one :
See those tests : https://regex101.com/r/oK0eS0/2 |
Alright cool, if you think this works, +1. I am not crazy about the syntax, but it's better than nothing. What about default values for a field? Ideas on that? |
Mmm, if we throw in default values, we need a more explicit syntax than we already have. Something more descriptive, closer to an array. Something like :
This way we can have whatever properties we need and adding them should not be that much hassle once the syntax is set. What do you think ? Do you have another idea ? |
What about:
? |
There would be no way to specify all of that in one statement ? |
I guess you could, but ideally we also support simpler methods |
A quick way of supporting nullable is doing something like this:
That emulates the nullable type hints of some languages, like hacklang |
@lorenzo I like the idea. |
I've worked on a quick patch that served my need recently. Being a former C# and Java developer, my thought aligned with @lorenzo 's suggested syntax Example:
I've put up my fork on GitHub at nitincoded/migrations I would love to be able to bring the changes into cakephp/migrations and I'm currently working on building the CI test cases. |
great news @nitincoded ! |
You are probably referring to master...nitincoded:patch-1 - you can directly link to your changes as diff this way to make it easier to communicate what you did. |
@dereuromark : Thank you for the heads up. This is my first go at contributing to a project on GitHub. The diff of the change is at: I also added a test for nullable columns to the PHPUnit test case, and submitted a pull request bearing the same name as this GitHub issue. |
PR #249 opened to add the feature. |
Add support for specifying a nullable field #203
This feature is being introduced in cakephp/migrations v1.6.3. Reference: Issue cakephp/migrations#203 / PR cakephp/migrations#249
Currently a user has to go in and manually update a migration if they want to allow the field to be nulled out, which is a bit annoying. It would be nice to be able to specify a nullable field, similar to how we do size.
Does anyone have any ideas around syntax for this?
The text was updated successfully, but these errors were encountered: