Last Updated: September 20, 2018
·
4.319K
· mattcodez

Remove enums in Sequelize / Postgres down migrations

If you are adding a new enum in your migrations, you may want to manually drop the type in your down() migration. This doesn't happen automatically it seems. See here: https://github.com/sequelize/sequelize/issues/2554

Example:
```
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addColumn('users', 'has_family', {
type: Sequelize.ENUM,
values: ['yes', 'no', 'maybe']
});
},

down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('users', 'hasfamily');
return queryInterface.sequelize.query(
'DROP TYPE "enum
usershasfamily";'
);
}
};
```