枚举thows类型的knex迁移创建类型已经存在

问题描述 投票:0回答:1

我正在尝试更改表中的列以将knex枚举修改为本机类型,以受益于Postgres的绑定系统,当我执行迁移时,我得到此错误类型"request_type" already exists,您知道这里发生了什么吗?] >

export async function up(knex: Knex): Promise<any> {
  return knex.schema.alterTable('appointments', table => {
    table.enu('type', ['video', 'physical'], { useNative: true, enumName: 'request_type' }).alter();
  });
}

export async function down(knex: Knex): Promise<any> {
  return knex.schema
    .alterTable('appointments', table => {
      table.dropColumn('type');
    })
    .then(() => knex.raw('CREATE TYPE request_type AS ENUM("video", "physical")'))
    .then(() => knex.raw('drop type request_type'));
}

我正在尝试更改表中的列以将knex枚举修改为本机类型,以受益于Postgres的绑定系统,当我执行迁移时,我已经收到此错误类型“ request_type”了...]]

postgresql migration database-migration knex.js
1个回答
0
投票

好像在knex中有一个bug,当更改这样的列时,它会导致创建类型查询被添加两次。

https://runkit.com/embed/xqtl8p2knhi8

© www.soinside.com 2019 - 2024. All rights reserved.