When removing nullability from a column, "smart defaults" does not migrate existing nulls to a default constraint's value.
- Dominant language
- C#
- Stars
- 460
- Forks
- 29
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 7
Description
### **Is your feature request related to a problem?**
This is probably a feature request, but could be interpreted as a bug. It's certainly not intuitive.
### **Please describe.**
Today I discovered "smart defaults" when trying to migrate some columns from nullable to not nullable.
I expected this feature would make its best effort during this migration to replace the now incompatible nulls with a sensible default, I.E. the new `DEFAULT` constraints I was adding to said columns.
It didn't do that, and now my columns now have the wrong values. Boooooo!
### **Describe the solution you'd like**
Replace existing null values with the value of the `DEFAULT` constraint when migrating a column to `NOT NULL`.
### **Describe alternatives you've considered**
Pre/post deployment scripts are an option, but that introduces additional state that isn't directly tracked by the project. The whole reason I like this pipeline is for its ability to sync schema in a few clicks without much thought.
Contributor guide
Research direction
Start by tracing the smart-defaults handling for migrations that change a nullable column to NOT NULL, then reproduce the case with existing NULL values and a new DEFAULT constraint. Verify the migration replaces those NULLs with the constraint value while preserving the intended schema change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100