fix(db): support clean test database initialization

This commit is contained in:
2026-08-26 21:17:14 +08:00
parent 0103ea96c8
commit 9b6e257f8d
2 changed files with 17 additions and 65 deletions
@@ -41,6 +41,15 @@ test('统一初始化 SQL 提供人工验收所需公共仓储主数据', () =>
assert.doesNotMatch(palletSeed, /\bstatus\b|'AVAILABLE'/)
})
test('国内统一初始化支持真实空库且不越界创建海外业务库', () => {
assert.doesNotMatch(sql, /CREATE DATABASE IF NOT EXISTS baiyue_lastleg|USE baiyue_lastleg;/)
assert.match(sql, /IF EXISTS \(SELECT 1 FROM information_schema\.tables WHERE table_schema=DATABASE\(\)[\s\S]*?table_name='fl_ocean_booking'\) THEN[\s\S]*?UPDATE fl_container_booking container_booking[\s\S]*?JOIN fl_ocean_booking ocean_booking/)
assert.ok(
sql.indexOf("table_name='fl_ocean_booking') THEN") < sql.indexOf('CREATE TABLE IF NOT EXISTS fl_ocean_booking ('),
'empty-database backfill must be guarded before the ocean-booking baseline is created',
)
})
test('三期权限迁移删除退役权限并只保留 canonical 权限', () => {
for (const source of [sql, oceanBookingSchema]) {
assert.match(source, /DELETE FROM iam_permission WHERE id IN \(5102141,5102143,5102144,5102145\)/)