重构:合并数据库迁移为三个领域文件

This commit is contained in:
yml2213
2026-11-08 20:07:18 +08:00
parent fcf8941972
commit d76e8265f8
23 changed files with 1475 additions and 1436 deletions
@@ -157,7 +157,7 @@ test('销售毛利必须同时暴露缺失成本收入,避免只看毛利绝
test('销售事实必须只统计已支付订单,并扣减已确认退款', async () => {
const [source, scopeMigration] = await Promise.all([
read(new URL('./sales-facts-channel-service.ts', import.meta.url)),
read(new URL('../../db/migrations/167_finance_derived_scope.sql', import.meta.url)),
read(new URL('../../db/migrations/149_finance_derived_scope.sql', import.meta.url)),
])
assert.ok(
scopeMigration.includes("order_record.pay_status IN ('paid', 'refunded')"),
@@ -6,7 +6,7 @@ function read(relativePath: string) {
return readFileSync(new URL(relativePath, import.meta.url), 'utf8')
}
const migration = read('../../db/migrations/167_finance_derived_scope.sql')
const migration = read('../../db/migrations/149_finance_derived_scope.sql')
const salesFacts = read('./sales-facts-channel-service.ts')
const ledger = read('./finance-ledger-service.ts')
const rebuild = read('../../../scripts/rebuild-finance-derived.ts')
@@ -7,7 +7,7 @@ function read(relativePath: string) {
}
const migration = read('../../db/migrations/140_fulfillment_state_events.sql')
const cutoverMigration = read('../../db/migrations/163_cutover_fulfillment_truth.sql')
const cutoverMigration = read('../../db/migrations/148_fulfillment_execution_truth.sql')
const stateService = read('./fulfillment-state-service.ts')
const channelAssign = read('./channel-assign-service.ts')
const carrierReconciliation = read('./carrier-reconciliation-service.ts')
@@ -15,15 +15,15 @@ const configSyncMigration = readFileSync(
'utf8',
)
const routeCutoverMigration = readFileSync(
new URL('../../db/migrations/161_move_shadow_sync_to_sku_routes.sql', import.meta.url),
new URL('../../db/migrations/147_internal_sku_product_routing.sql', import.meta.url),
'utf8',
)
const truthCutoverMigration = readFileSync(
new URL('../../db/migrations/163_cutover_fulfillment_truth.sql', import.meta.url),
new URL('../../db/migrations/148_fulfillment_execution_truth.sql', import.meta.url),
'utf8',
)
const insertSkuMigration = readFileSync(
new URL('../../db/migrations/166_fulfillment_insert_resolved_sku.sql', import.meta.url),
new URL('../../db/migrations/148_fulfillment_execution_truth.sql', import.meta.url),
'utf8',
)
@@ -35,7 +35,7 @@ test('正式履约模型包含履约、尝试和异常三张表', () => {
assert.ok(migration.includes('UNIQUE (fulfillment_id, issue_code)'))
})
test('迁移 163 删除影子双写并直接维护正式履约真源', () => {
test('迁移 148 删除影子双写并直接维护正式履约真源', () => {
assert.ok(
truthCutoverMigration.includes('DROP TRIGGER IF EXISTS trg_order_items_fulfillment_shadow'),
)