简体   繁体   English

用 postgreSQL 续集 nodejs 中的迁移错误并表达 JS

[英]Sequelize migration error in nodejs with postgreSQL and express JS

first, I created a wrong migration so delete a migration file.but when i try to run new migration it show the error of old migration as error: "Error in running migrations column \"is_ac\" of relation \"users\" already exists i am using sequelize with node js and postgreSql. is_ac migration file already deleted.首先,我创建了一个错误的迁移,因此删除了一个迁移文件。但是当我尝试运行新迁移时,它显示旧迁移的错误为错误:“运行迁移列中的错误”is_ac“关系“用户”已经存在我正在使用节点 js 和 postgreSql 的 sequelize。is_ac 迁移文件已删除。

Delete "is_ac migration" migration file from the database table "SequelizeMeta".从数据库表“SequelizeMeta”中删除“is_ac migration”迁移文件。 See if that works.看看这是否有效。

thanks to all .issue was in my azure pipeline.i was not deleting old migration from zip.the new code is ....
"use strict";
const tableName = "jobs";
const columnName = "job_deposit_taken";

module.exports = {
  up: (queryInterface, Sequelize) => {
    const columnType = Sequelize.JSONB;
    return queryInterface.describeTable(tableName).then(tableDefinition => {
      if (!tableDefinition[columnName]) {
        return queryInterface.addColumn(tableName, columnName, columnType);
      } else {
        return Promise.resolve();
      }
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.removeColumn(tableName, columnName);
  }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM