Jira issue originally created by user @beberlei:
This issue is created automatically through a Github pull request on behalf of deeky666:
This PR fixes altering column default values. In SQL Server column default values are stored in constraints. CREATE TABLE statements with column declarations like somecolumn NVARCHAR(50) NOT NULL DEFAULT 'default value' internally creates a default constraint with an automatically generated name in the the system table `sys.defaultconstraints`. ALTER TABLE statements do not support the DEFAULT clause in column alteration declarations, leading in SQL syntax errors. Thus changing a column's default value is currently not possible.
To alter a column's default value, the old column's default constraint hast to be dropped and recreated again. As a default constraint has to be referenced by name to be dropped, we need to create each default constraint with an own unique name. This PR generates separate statements for default constraint declarations. It generates a unique name consisting of the table name and the column name the default constraint is created for.
somecolumn NVARCHAR(50) NOT NULL DEFAULT 'default value'
Comment created by @beberlei:
A related Github Pull-Request [GH-298] was closed
Issue was closed with resolution "Fixed"
Comment created by @doctrinebot:
A related Github Pull-Request [GH-298] was closed: