gpt4 book ai didi

sql - 旧的 sequelize 迁移没有运行,如何重新运行它

转载 作者:行者123 更新时间:2023-12-03 22:31:11 27 4
gpt4 key购买 nike

我有一个通过 sequelize 连接的数据库。我有多个环境,由于某种原因,特定的迁移没有在生产中运行,但似乎在我们的开发、暂存和测试数据库上按预期进行了。从那时起,已经运行了多次迁移。在识别为已运行后,是否可以安全地重新运行特定迁移?
迁移名称是 20210316102540-delete_clothes_columns_expired_in_webshop_and_in_store.js迁移没有 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

关于sql - 旧的 sequelize 迁移没有运行,如何重新运行它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66738485/

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