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
Alter queries generated by sequelize.sync with alter: true report syntax problems when columns use an explicit defaultValue #9058
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
Unfortunately I'm facing the same problem currently. SQL Server 2019. Apparently the syntax for setting a DEFAULT value to an existing column is different in SQL SERVER, causing this exception, exactly as explained by user @jsanta :(
Any solution? I had to disable sync() to be able to work with my API.
I am still having this issue in 6.37.3 over 4 years later. The workaround of using a function instead of a literal value when using changeColumn worked for me. When using addColumn it worked better with a literal value.
Still an issue. Cannot migrate modified models with a default value column.
sequelize: 6.37.3
tedious: 18.2.0
...
Executing (bdb79bb2ea41f506432f): ALTER TABLE [Users] ALTER COLUMN [status] NVARCHAR(10) NOT NULL DEFAULT N'ACTIVE';
Executing (bdb79bb2ea41f506432f): ROLLBACK TRANSACTION;
ERROR: SequelizeDatabaseError: Incorrect syntax near the keyword 'DEFAULT'.
at Query.run (...\node_modules\sequelize\lib\dialects\mssql\query.js:107:25)
at ...\node_modules\sequelize\lib\sequelize.js:315:28
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Activity
sushantdhiman commentedon Feb 16, 2018
Can you try with latest version
stale commentedon May 17, 2018
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
jsanta commentedon May 22, 2018
Tried the latest version.
Still getting the same error. MS SQL Server syntax for altering a column default value is different. Refer to https://stackoverflow.com/questions/6791675/how-to-set-a-default-value-for-an-existing-column
sushantdhiman commentedon May 23, 2018
http://docs.sequelizejs.com/class/lib/model.js~Model.html#static-method-init
luisotavio-dev commentedon Jun 24, 2022
Unfortunately I'm facing the same problem currently. SQL Server 2019. Apparently the syntax for setting a DEFAULT value to an existing column is different in SQL SERVER, causing this exception, exactly as explained by user @jsanta :(
Any solution? I had to disable sync() to be able to work with my API.
pn-andrej-zecevic commentedon May 30, 2024
I am still having this issue in 6.37.3 over 4 years later. The workaround of using a function instead of a literal value when using
changeColumnworked for me. When usingaddColumnit worked better with a literal value.kieran-reportabl commentedon Jun 25, 2024
Still an issue. Cannot migrate modified models with a default value column.
sequelize: 6.37.3
tedious: 18.2.0