feat: 支持批量上传关卡
This commit is contained in:
26
prisma/rebalance-sort-keys.ts
Normal file
26
prisma/rebalance-sort-keys.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 一次性脚本:把所有关卡的 sortKey 重新分配成 a... 递增序列,
|
||||
* 消除历史上因"插到头部"产生的 Z 系列 key。
|
||||
*
|
||||
* 背景:MySQL 默认 collation 大小写不敏感,把 `Zz` 和 `zz` 视作相等,
|
||||
* 这会和 fractional-indexing 的字节序排序冲突。虽然应用层已切到 JS 排序,
|
||||
* 运行一次这个脚本可以让 DB 数据和 JS 排序"视觉上"也一致,方便排查。
|
||||
*
|
||||
* 运行:pnpm tsx prisma/rebalance-sort-keys.ts
|
||||
*/
|
||||
import { rebalanceAllKeys } from '../lib/sort-key'
|
||||
import { prisma } from '../lib/prisma'
|
||||
|
||||
async function main() {
|
||||
const count = await rebalanceAllKeys()
|
||||
console.log(`rebalanced ${count} levels`)
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
Reference in New Issue
Block a user