fix(deploy): sync inbound fee pricing columns

This commit is contained in:
2026-09-08 20:23:02 +08:00
parent 11076cef00
commit da5cf0eb64
2 changed files with 61 additions and 0 deletions
@@ -0,0 +1,22 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const unified = readFileSync(new URL('../deploy/sql/头程数据库统一增量-MySQL8.sql', import.meta.url), 'utf8')
const firstleg = readFileSync(new URL('../firstleg/src/main/resources/db/phase2-inbound-schema.sql', import.meta.url), 'utf8')
test('统一增量与 Firstleg 入库费用计费基准和容差字段一致', () => {
for (const source of [unified, firstleg]) {
assert.match(source, /baseline_chargeable_quantity DECIMAL\(18,6\) NOT NULL/)
assert.match(source, /tolerance_percent DECIMAL\(5,2\) NOT NULL DEFAULT 10\.00/)
assert.match(source, /SET baseline_chargeable_quantity = chargeable_quantity\s+WHERE baseline_chargeable_quantity IS NULL/)
assert.match(source, /MODIFY COLUMN baseline_chargeable_quantity DECIMAL\(18,6\) NOT NULL/)
}
})
test('统一增量最终检查阻止缺少入库费用计费字段的部署通过', () => {
const finalAssertion = unified.slice(unified.indexOf('CREATE PROCEDURE assert_unified_final_schema()'))
assert.match(finalAssertion, /column_name='baseline_chargeable_quantity'[\s\S]*numeric_precision=18 AND numeric_scale=6/)
assert.match(finalAssertion, /column_name='tolerance_percent'[\s\S]*numeric_precision=5 AND numeric_scale=2/)
assert.match(finalAssertion, /统一迁移失败:入库费用基准计费量或容差字段不完整/)
})