gpt4 book ai didi

postgresql - 如何撤消 sequelize 迁移枚举类型

转载 作者:行者123 更新时间:2023-12-03 22:19:17 25 4
gpt4 key购买 nike

我使用 PostgreSQL DB,它有一个 enum 类型列,它有一些 enum,如 a,b,c
现在我使用此代码在其中添加了一个值,例如 cv-resume

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.query('ALTER TYPE "enum_Attachment_type" ADD VALUE \'cv-resume\' ')
}
我应该怎么做才能在 down 函数中撤消它,而且我不想删除其他枚举类型的数据
因为每种类型在附件表中都有自己的数据

最佳答案

documentation :

Although enum types are primarily intended for static sets of values,there is support for adding new values to an existing enum type, andfor renaming values (see ALTER TYPE). Existing values cannot beremoved from an enum type, nor can the sort ordering of such values bechanged, short of dropping and re-creating the enum type.


因此,除了删除和重新创建枚举之外,我看不到任何其他“撤消”方法。
更新:检查 Drop and create ENUM with sequelize correctly?

关于postgresql - 如何撤消 sequelize 迁移枚举类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64264197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com