oms/backend/database/migrations/20260916030200-cleanup-superseded-migration-records.js
liufumingren 6c03a20364 feat(backend): 订单状态分表、WMS 推送与归档
- 新增 order_index 索引表 + 6 张同构状态表(待审核/异常/委外中/配送/已作废/已取消)与历史表,
  订单 ID 全局唯一,状态由业务事务推动:审核、驳回、取消、作废、恢复、归档
- 明细表 order_status_items、收件人文本智能解析、批量切换仓库/店铺并刷新快照
- WMS deliveryorder.create 推送(单条/批量)、推送失败定时重试、订单归档定时任务
- 迁移:建表、旧发货单数据迁入新表、菜单合并与迁移记录清理
- routes / swagger contract 补充订单状态接口

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-30 23:06:18 +08:00

41 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 清理已被取代的迁移记录(sequelize_meta)。
*
* 背景:本模块最初按「拆单(split order)」语义命名并留下 4 个迁移文件
* (建表 / 菜单种子 / 结构对账 / 菜单调整),尚未发布到生产即确认语义有误,
* 已整体改名为订单语义并合并为:
* - 20260916030000-create-order-tables.js(建表 + 旧命名表就地改名)
* - 20260916030100-order-menu-to-order-page.js(订单菜单口径)
* 由于旧文件已删除,其在本地的执行记录(sequelize_meta)会变成"找不到文件"的孤儿记录,
* 本迁移把这些记录清掉,保证 `db:migrate:status` 与 `db:migrate:undo` 干净可用。
*
* down:不可逆(仅是执行记录清理,不影响任何业务表结构)。
*/
const SUPERSEDED = [
'20260915010000-create-split-order-tables.js',
'20260915010100-seed-split-order-menu.js',
'20260916010000-reconcile-split-order-tables.js',
'20260916020000-order-menu-use-split-order-page.js',
];
module.exports = {
async up(queryInterface) {
const [ rows ] = await queryInterface.sequelize.query(
'SELECT name FROM sequelize_meta WHERE name IN (?)',
{ replacements: [ SUPERSEDED ] }
);
if (!rows.length) return;
await queryInterface.sequelize.query(
'DELETE FROM sequelize_meta WHERE name IN (?)',
{ replacements: [ SUPERSEDED ] }
);
console.log(`[order] 已清理 ${rows.length} 条被取代的迁移记录:${rows.map(row => row.name).join(', ')}`);
},
async down() {
// 不可逆:被取代的迁移文件已删除,不需要也无法恢复其执行记录
},
};