Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

@joethefkingfrypan/sequelize-replace-enum-postgres

1.6.0-rc1 • Public • Published

Replace ENUM PostgreSQL

Build Status NPM version

This package provides the methods needed to replace a PostgreSQL ENUM in Sequelize migrations.

Install

npm install --save sequelize-replace-enum-postgres

How to use

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'
    });
  }
};

Mantainers

Issues

Install

npm i @joethefkingfrypan/sequelize-replace-enum-postgres

DownloadsWeekly Downloads

18,033

Version

1.6.0-rc1

License

ISC

Unpacked Size

32.9 kB

Total Files

14

Last publish

Collaborators

  • avatar