testingmigrationsequelize.js

How to test Sequelize migrations?


Is it necessary to cover Sequelize migrations with unit tests, or even functional tests to check how they affect DB structure? If so, how to do it?


Solution

  • Imho testing migrations is not necessary. Neither for sequelize nor any other decent ORM.

    1. Migrations describe how your database must be altered to become compliant with the current state of the application that uses it. In a sense they are therefore not part of the application itself. Therefore no testing required.
    2. Migrations typically don't implement any custom logic. They just call a bunch of methods of the migration library. And the library used should itself be thoroughly unit tested. Therefore no additional testing required.