'Sequelize best practices syncing database development vs. production

The documentation for Sequelize states that sequelize.sync() shoudln't be used on production, as it is potentially destructive. Instead, migrations should be used.

Therefore, I am wondering what the best practices are for using sequelize.sync().

Is it common to use environment variables to check if the current environment is development? Like such:

if (process.env.NODE_ENV === 'development') {
    sequelize.sync({ force: true });
}

That way, the database would only be synced in a development environment.

Otherwise, is it common this time to simply not use sync at all, even in a development environment, and use regular migrations?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source