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 "enumusershasfamily";'
);
}
};
```
Written by mattcodez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Node
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#