chore(db): 成本中心迁移重编号到 main 之后(103–106),check:sql 允许纯重编号
This commit is contained in:
@@ -118,6 +118,7 @@ try {
|
||||
.flatMap((output) => output.split('\n'))
|
||||
.map((line) => line.trim().split(/\s+/))
|
||||
.filter(([status, file]) => status && file?.endsWith('.sql') && status !== 'A')
|
||||
.filter(([status, file, renamedTo]) => !isMigrationRenumber(status, file, renamedTo))
|
||||
.map(([status, file]) => `${status} ${file}`)
|
||||
.filter((change) => !allowedHistoricalMigrationChanges.has(change))
|
||||
if (changedHistoricalMigrations.length > 0) {
|
||||
@@ -127,6 +128,21 @@ try {
|
||||
failures.push(`历史迁移完整性检查失败: ${error instanceof Error ? error.message : String(error)}`)
|
||||
}
|
||||
|
||||
// 分支合流后把尚未上线的迁移顺延到主线版本号之后时,只允许改序号前缀,
|
||||
// 文件名主体必须完全一致(例:102_product_catalog.sql -> 103_product_catalog.sql)。
|
||||
function isMigrationRenumber(
|
||||
status: string | undefined,
|
||||
renamedFrom: string | undefined,
|
||||
renamedTo: string | undefined,
|
||||
) {
|
||||
if (!status?.startsWith('R') || !renamedFrom || !renamedTo) return false
|
||||
return stripMigrationPrefix(renamedFrom) === stripMigrationPrefix(renamedTo)
|
||||
}
|
||||
|
||||
function stripMigrationPrefix(filePath: string) {
|
||||
return path.basename(filePath).replace(/^\d{3}_/, '')
|
||||
}
|
||||
|
||||
for (const check of checks) {
|
||||
if (!fs.existsSync(check.file)) {
|
||||
failures.push(`${check.name}: 文件不存在 ${check.file}`)
|
||||
|
||||
Reference in New Issue
Block a user