Sequelize v7 is the next major release after v6. Below is a list of breaking changes to help you upgrade.
Sequelize v7 will only support those versions of Node.js that are compatible with the ES module specification, namingly version 12 and upwards #5.
One of the major foundational code changes of v7 is the migration to TypeScript. As a result, the manual typings that were formerly best-effort guesses on top of the JavaScript code base, have been removed and all typings are now directly retrieved from the actual TypeScript code. You'll likely find many tiny differences which however should be easy to fix.
This only impacts you if you used ConnectionManager
directly.
ConnectionManager#getConnection
: The type
option now accepts 'read' | 'write'
instead of 'SELECT' | any
.
It was already documented as such in v6, but the implementation did not match the documentation.
// Instead of doing this:
sequelize.connectionManager.getConnection({ type: 'SELECT' });
// Do this:
sequelize.connectionManager.getConnection({ type: 'read' });
Sequelize v7 fully supports MS SQL Server 2017 (version 14) onwards, up from 2012 (version 13) in Sequelize v6, as this matches Microsoft's own mainstream support.
Model.findOne
and Model.findAll
are used respectively by Model.findByPk
and Model.findOne
.
This is considered an implementation detail and as such, starting with Sequelize v7,
overrides of either of these methods will not be called internally by Model.findByPk
or Model.findOne
.
In other words, doing this won't break:
class User extends Model {
static findOne() {
throw new Error('Do not call findOne');
}
}
// this would have thrown "Do not call findOne" in v6
// but it works in v7
User.findByPk(1);