Repository navigation
Conversation
|
Sorry for neglecting this PR for so long @fduch2k !! The code looks good, can you add some tests as well? Both integration test (calling the function) and unit tests (testing that the generated sql is correct) would be nice |
|
Sure, I'll add tests |
|
Sweet, and thanks for the quick reply! (which is more than you can say about us...) Remember to rebase so your tests can be run on travis |
|
Hi! My team is a bit anal about all constraint names (fk, pk, etc) in mssql, for reasons, so I customized sequelize a bit to generate them with a default name (similar to what was done in this PR) and also to offer the ability to specify the names by yourself. You can check it here: Maybe we can join these modifications? My idea is receiving the custom constraint names in the |
|
@bassarisse That sounds like a good addition! |
Current version of mssql query-generator generate incorrect sql code for changing column default value.
E.g. migration.changeColumn('Users', 'flags', {type: DataTypes.INTEGER, defaultValue: 1}); generate next code:
but this code is generate next error:
After some researching I found that in tsql default values implemented over constraints, so changing value should be s.th. like this:
This patch implements described behavior by adding constraint with name df_tablename_fieldname for default values.
Useful links:
http://stackoverflow.com/questions/2095289/sql-server-alter-column-adding-default-constraint
http://stackoverflow.com/questions/1782714/declaring-a-default-constraint-when-creating-a-table
http://stackoverflow.com/questions/92082/add-a-column-with-a-default-value-to-an-existing-table-in-sql-server