mssql: schema builder - attempt to drop default constraints when changing default value on columns #4321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #4319
When changing a default value on a column in mssql, the previous default constraint needs to be dropped before a new one can be assigned. This PR attempts to drop the constraint and then adds the constraint via a separate query:
Help required:
I've tried to get a grasp of how the internals of the builder work for this and implemented this in a way that I think makes the most sense.
Under some circumstances this change can result in a needless alter query being run when the only change to a column is its default value; in this case we should only be running the drop and add constraint queries, but I'm not clear on how best to skip the other query that is produced under these circumstances.
To do: