-
Notifications
You must be signed in to change notification settings - Fork 64
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 change nullability statement #1041
Add change nullability statement #1041
Conversation
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.
Nice! Let's give this a shot 🚀
* Implement allow_nulls_for and forbid_nulls_for * Remove leftover macro, fix ordering of change default with respect to change type * Implement have_any? criteria * Add change nullability statement (#1041) * Implement allow_nulls_for and forbid_nulls_for * Remove leftover macro, fix ordering of change default with respect to change type * Prevent users from assuming boolean result * Implement allow_nulls_for and forbid_nulls_for * Remove leftover macro, fix ordering of change default with respect to change type * Implement have_any? criteria * Prevent users from assuming boolean result
@davidepaolotua I was just writing up some documentation and it just occurred to me.... why did we add avram/src/avram/migrator/change_null_statement.cr Lines 13 to 24 in bec9058
avram/src/avram/migrator/alter_table_statement.cr Lines 104 to 106 in bec9058
I'm sure there was some logic behind having a second way to do this, but I'm not seeing why, and I don't remember 😅 |
Uhm... I wish I was as sure as you are... imho I just completely missed the existence of that method - I prolly just looked in the alter_table file, and didn't occur to me that there was actually a separated file only for that case, while the other change_xxx are in alter table ^^' we actually could remove those methods imho (just keeping the fix for the ordering of the ddl statements) |
Ok. I'll at least open an issue on it. I'm sure I just forgot about the other methods too at the time 😂 |
This PR attempts to fix two things:
provide a way to change the nullability of a column in the migrator.
Related to #1039
Two new macros have been created:
it is split from the change_type statement, so that you can theoretically do something like
changes the order of the change_default statement with respect to the change_type statement
Currently, if you had something like:
it would generate first the change of default, then the change of type, which is probably counterintuitive.
Now, it generates first the change of type, then the change of default