Default value in migrations without future auto-completion #54144
Unanswered
MrShnaider
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I come across such situations quite often. I have an existing table and I want to add a new column. After the migration, all existing rows should have some default value in this column. I can do this using the
default
method in the Blueprint instance:The problem is that this will not only add a default value to existing rows, but it will also add that value in the future if the value is not provided at creation. I want the first behavior, but I don't want the second. As I see it, there is currently no mechanism for making such changes.
It can probably be implemented like this:
Or write an sql query directly in the migration. But I probably would like to see such a method in the library itself.
Can you tell me if the
change
option will work? And if it is possible to add a method with this behavior to the "Blueprint" class?Beta Was this translation helpful? Give feedback.
All reactions