{"id":43815,"library":"sequelize-replace-enum-postgres","title":"sequelize-replace-enum-postgres","description":"Utility for replacing PostgreSQL ENUM values in Sequelize migrations. Version 1.6.0 is current, with irregular release cadence. It provides a single function to safely add/remove enum values without dropping and recreating the column, avoiding common pitfalls. Key differentiator: handles complex cases like columns with default values and custom enum names, unlike raw SQL approaches. Only supports PostgreSQL with Sequelize.","status":"active","version":"1.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/abelosorio/sequelize_replace_enum_postgres","tags":["javascript","NodeJS","PostgreSQL","ENUM","Migration","Sequelize"],"install":[{"cmd":"npm install sequelize-replace-enum-postgres","lang":"bash","label":"npm"},{"cmd":"yarn add sequelize-replace-enum-postgres","lang":"bash","label":"yarn"},{"cmd":"pnpm add sequelize-replace-enum-postgres","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default export. Also available via require with .default property.","wrong":"const replaceEnum = require('sequelize-replace-enum-postgres');\n// This works but is not the default import","symbol":"replaceEnum","correct":"import replaceEnum from 'sequelize-replace-enum-postgres'"},{"note":"CommonJS usage requires accessing .default property.","wrong":"const replaceEnum = require('sequelize-replace-enum-postgres');\n// Function will be the module.exports object, not the function itself","symbol":"default","correct":"const replaceEnum = require('sequelize-replace-enum-postgres').default;"}],"quickstart":{"code":"import replaceEnum from 'sequelize-replace-enum-postgres';\n\nexport default {\n  up: (queryInterface, Sequelize) => {\n    return replaceEnum({\n      queryInterface,\n      tableName: 'eventRecurrence',\n      columnName: 'recurrenceType',\n      defaultValue: 'weekly',\n      newValues: ['weekly', 'monthly', 'yearly', 'on-demand'],\n      enumName: 'enum_event_recurrence_recurrence_type'\n    });\n  },\n  down: (queryInterface, Sequelize) => {\n    return replaceEnum({\n      queryInterface,\n      tableName: 'eventRecurrence',\n      columnName: 'recurrenceType',\n      defaultValue: 'weekly',\n      newValues: ['weekly', 'monthly', 'yearly'],\n      enumName: 'enum_event_recurrence_recurrence_type'\n    });\n  }\n};","lang":"javascript","description":"Migration using replaceEnum to add 'on-demand' to an existing ENUM column."},"warnings":[{"fix":"Always provide the exact PostgreSQL enum name as shown in the database schema.","message":"Enum name parameter (enumName) is required but often omitted, causing unexpected errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure defaultValue is among the current enum values (not an empty string or invalid).","message":"Default value (defaultValue) must match one of the existing enum values, otherwise the migration will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually drop dependencies before running the migration, or use a transactional approach.","message":"The function does not support altering columns with dependencies (views, other tables) referencing the enum type.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure newValues is the complete set of enum values after migration.","message":"The newValues array must include all existing values plus new ones, not just the ones to add.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.6.0':16 'add/remove':30 'approach':59 'avoid':39 'cadenc':22 'case':46 'column':38,48 'common':40 'complex':45 'current':18 'custom':53 'default':50 'differenti':43 'drop':34 'enum':4,10,31,54,68 'function':27 'handl':44 'irregular':20 'javascript':65 'key':42 'like':47 'migrat':14,69 'name':55 'nodej':66 'pitfal':41 'postgr':5 'postgresql':9,62,67 'provid':24 'raw':57 'recreat':36 'releas':21 'replac':3,8 'safe':29 'sequel':2,13,64,70 'sequelize-replace-enum-postgr':1 'singl':26 'sql':58 'support':61 'unlik':56 'util':6 'valu':11,32,51 'version':15 'without':33","created_at":"2026-06-05T17:01:36.365082+00:00","updated_at":"2026-06-05T17:01:36.365082+00:00","problems":[{"fix":"Use require('sequelize-replace-enum-postgres').default to get the function.","cause":"CommonJS import returns the module.exports object, which has a default property.","error":"const replaceEnum = require('sequelize-replace-enum-postgres'); replaceEnum(...) is not a function"},{"fix":"Use 'import replaceEnum from \"sequelize-replace-enum-postgres\"'","cause":"ESM import statement missing or incorrect path.","error":"replaceEnum is not defined"},{"fix":"Double-check the exact column and table names from your Sequelize models.","cause":"Incorrect columnName or tableName passed to function.","error":"column \"columnName\" of relation \"tableName\" does not exist"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/abelosorio/sequelize_replace_enum_postgres#readme","github":"https://github.com/abelosorio/sequelize_replace_enum_postgres","docs":null,"changelog":null,"pypi":null,"npm":"sequelize-replace-enum-postgres","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}