sequelize_enum_utils
Version:
Utils for enum handling in sequelize migrations with postgres
56 lines (39 loc) • 1.25 kB
Markdown
for easier manipulation of **PostgreSQL** ENUMs in **Sequelize** migrations.
```
npm install sequelize_enum_utils
```
In this migration we are removing the `PENDING` value from the `enum_transaction_status` and specify the default value `ACCEPTED`, this will affect all the columns and tables that are currently using the provided enum:
```js
'use strict';
const { enumUtils } = require('sequelize_enum_utils');
module.exports = {
up: async (queryInterface, Sequelize) => {
await enumUtils.removeMember({
queryInterface,
enumName: 'enum_transaction_status',
enumMembersToRemove: ['PENDING'],
defaultEnumValue: 'ACCEPTED',
});
},
down: async (queryInterface, Sequelize) => {
// Revert changes
},
};
```
Params:
```js
{
queryInterface: QueryInterface;
enumName: string;
enumMembersToRemove: string[];
defaultEnumValue: string; //Optional
}
```
If no `defaultEnumValue` is provided, the affected columns will be set to `null`
In version `1.0.0`, only the `removeMember` method is available.
- **[Federico Antunes](https://github.com/FedericoAntunesDev)**
This package provides utilities