Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 2.14 KB

upgrade-to-v7.md

File metadata and controls

58 lines (40 loc) · 2.14 KB

Upgrade to v7

Sequelize v7 is the next major release after v6. Below is a list of breaking changes to help you upgrade.

Breaking Changes

Support for Node 12 and up

Sequelize v7 will only support those versions of Node.js that are compatible with the ES module specification, namingly version 12 and upwards #5.

TypeScript conversion

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.

Changes to ConnectionManager

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' });

Microsoft SQL Server Support

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.

Overridden Model methods won't be called internally

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);