old sequelize migration 没有运行,如何重新运行呢

old sequelize migration did not run, how to re run it

我有一个通过 sequelize 连接的数据库。我有多个环境,由于某种原因,特定的迁移在生产环境中没有 运行,但在我们的开发、暂存和测试数据库中似乎按预期进行了。从那以后,多次迁移运行。是否可以安全地重新运行 一个特定的迁移被识别为 运行?

迁移名称是[​​=14=]

迁移没有down功能,所以也许我可以db:migrate:undo --name 20210316102540-delete_clothes_columns_expired_in_webshop_and_in_store.jsdb:migrate之后?这是一种安全的方法吗?

20210316102540-delete_clothes_columns_expired_in_webshop_and_in_store.js

'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    queryInterface.sequelize.transaction(async (t) => {
    await queryInterface.sequelize.query(`UPDATE clothes SET status = 'ACTIVE' WHERE in_store = TRUE AND status = 'IDLE';`, {transaction: t})
    await queryInterface.removeColumn('clothes', 'in_webshop', {transaction: t})
    await queryInterface.removeColumn('clothes', 'expired', {transaction: t})
    await queryInterface.removeColumn('clothes', 'in_store', {transaction: t})
    })
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
  }
};

确保它已经运行

production=# select * from "SequelizeMeta";
                                          name                                           
-----------------------------------------------------------------------------------------
 ...
 20210316102540-delete_clothes_columns_expired_in_webshop_and_in_store.js
 ...
(11 rows)

我仍然不确定为什么没有迁移 运行。但我最终删除了 SequelizeMeta 中的行并重新运行它。

delete from "SequelizeMeta" where name = '20210316102540-delete_clothes_columns_expired_in_webshop_and_in_store.js';

sequelize-cli db:migrate