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
Changing default value with changeColumn does not work in SQL Server #7403
// In SQL Server...queryInterface.changeColumn('my_table','my_column',{type: Sequelize.INTEGER,defaultValue: 0,allowNull: false,})
What do you expect to happen?
It should successfully change the column data type and the default value.
What is actually happening?
The SQL generated does not work : ALTER TABLE [my_table] ALTER COLUMN [my_column] INTEGER NOT NULL DEFAULT 0; gives Incorrect syntax near the keyword \'DEFAULT\'
Sorry, for my ignorance but how does this pull request have solved the original problem?
All I see is that handling constraints have been added but it doesn't appear to be used in the changeColumn.
Am i wrong?
Reacted by Jared Sim, Francis Brito, Alejandro Corredor, Karol Burdziński, Tasos Boulis, Anandha Moorthy, AdithyaBhat, gavin belson, Lucas Kenji, joaopedr0vieira and 4 more
Activity
joshuapaling commentedon Mar 21, 2017
Further to this, even just changing the type of a column without changing the default value might not work if the column has an existing default value. So even just to change the type, I'm pretty sure you need to drop the constraint which enforces the existing default value first. Perhaps not if the old and new types are compatible - eg. INT and BIG INT. This answer has some info on that: http://stackoverflow.com/a/10758357/1373987
harshithkashyap commentedon Mar 21, 2017
This will be solved by #7108
Xenope commentedon Jan 29, 2019
Sorry, for my ignorance but how does this pull request have solved the original problem?
All I see is that handling constraints have been added but it doesn't appear to be used in the changeColumn.
Am i wrong?