You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
queryInterface.removeColumn fails during migration #4943
removeColumn will fail because of defaultValue constraint.
And I can't set up a name for the constraint so it's not convenient to remove the constraint with plain sql query (query becomes more complex because I need to get the constraint's name firstly)
I was not aware, too, but now I am aware) Thanks to ms.
Sequelize error message: Unhandled rejection SequelizeDatabaseError: ALTER TABLE DROP COLUMN ColumnName failed because one or more objects access this column.
sql> ALTER TABLE TableName DROP COLUMN ColumnName
[2015-11-2915:00:28] [S0001][5074] The object 'DF_TableName_ColumnName is dependent on column 'ColumnName'.
Because of
ALTERTABLE TableName
ADD CONSTRAINT DF_TableName_ColumnName
DEFAULT N'some value' FOR ColumnName;
When I use queryInterface.addColumn with defaultValue behavior is the same, just the name of constraint is not so beautiful because ORM auto-generates it.
See this discussion on social.msdn.microsoft.com. It's a common problem. Unfortunetaly, I can't find any official ms docs about it.
Workaround: just use queryInterface.sequelize.query instead of addColumn/removeColumn methods if the column has a default value.
Activity
mickhansen commentedon Nov 29, 2015
I was not aware that default values could constrain the table in any way.
Can you post the SQL called and the full error message?
apsavin commentedon Nov 29, 2015
I was not aware, too, but now I am aware) Thanks to ms.
Sequelize error message:
Unhandled rejection SequelizeDatabaseError: ALTER TABLE DROP COLUMN ColumnName failed because one or more objects access this column.Because of
When I use
queryInterface.addColumnwithdefaultValuebehavior is the same, just the name of constraint is not sobeautifulbecause ORM auto-generates it.See this discussion on social.msdn.microsoft.com. It's a common problem. Unfortunetaly, I can't find any official ms docs about it.
Workaround: just use
queryInterface.sequelize.queryinstead ofaddColumn/removeColumnmethods if the column has a default value.Columns with default values can be removed in MSSQL
Columns with default values can be removed in MSSQL
MichaelKearnsSoftwire commentedon Dec 7, 2015
This is also an issue my team has been working around for a while.
I've submitted a PR for this -- if somebody could take a look that would be useful.
Columns with default values can be removed in MSSQL
Columns with default values can be removed in MSSQL
harshithkashyap commentedon Nov 25, 2016
PR #4990 has been merged. This issue should be closed.