sequelize-replace-enum-postgres
Version:
This package provides the methods needed to replace a PostgreSQL ENUM in Sequelize migrations.
55 lines (39 loc) • 1.54 kB
Markdown
//travis-ci.org/abelosorio/sequelize_replace_enum_postgres.svg?branch=master)](https://travis-ci.org/abelosorio/sequelize_replace_enum_postgres) [](https://www.npmjs.com/package/sequelize-replace-enum-postgres)
This package provides the methods needed to replace a **PostgreSQL** ENUM in **Sequelize** migrations.
```
npm install --save sequelize-replace-enum-postgres
```
In this migration we are adding the `on-demand` value to the `recurrenceType` field of `eventRecurrence`:
```
'use strict';
const replaceEnum = require('sequelize-replace-enum-postgres').default;
module.exports = {
up: (queryInterface, Sequelize) => {
return replaceEnum({
queryInterface,
tableName: 'eventRecurrence',
columnName: 'recurrenceType',
defaultValue: 'weekly',
newValues: ['weekly', 'monthly', 'yearly', 'on-demand'],
enumName: 'enum_event_recurrence_recurrence_type'
});
},
down: (queryInterface, Sequelize) => {
return replaceEnum({
queryInterface,
tableName: 'eventRecurrence',
columnName: 'recurrenceType',
defaultValue: 'weekly',
newValues: ['weekly', 'monthly', 'yearly'],
enumName: 'enum_event_recurrence_recurrence_type'
});
}
};
```
* **[Abel M. Osorio](https://github.com/abelosorio)**
* https://github.com/abelosorio/sequelize_replace_enum_postgres/issues
[![Build Status](https: