迁移 104 里对 order_items 的全表 UPDATE 实测 34.4 秒(375,447 行), 远超默认语句超时 15s,单事务迁移会拖住启动甚至直接失败。 - 104 只保留 DDL 与索引/约束,删除全表 UPDATE; - 新增 scripts/backfill-revenue-basis.ts:按 id 分批、幂等、支持 --dry-run / --batch-size / --max-batches(kebab 与 camel 两种写法); - package.json 增加 revenue:backfill; - migrate.ts 启动时做一次带索引计数,仍有 unknown 时打印告警并给出命令, 不阻塞启动; - 文档补充回填步骤与「不执行的后果」。 验证: - 实测 37.5 万行全表更新 34.4s → 脚本按批执行,单批 5000 行; - 功能验证:单条订单项置 unknown → 脚本回填 → 金额与 basis 恢复正确; - 启动告警验证:保留 1 条 unknown 重启 → 日志出现告警;回填后计数归零; - 全新库从 102 迁移到 107 仍成功(2s)。
63 lines
3.1 KiB
JSON
63 lines
3.1 KiB
JSON
{
|
|
"name": "order-site-backend",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"cleanup:dev-data": "tsx scripts/cleanup-dev-data.ts",
|
|
"build": "tsc -p tsconfig.build.json && rm -rf dist/db/migrations && mkdir -p dist/db && cp -R src/db/migrations dist/db/migrations && mkdir -p dist/services/platforms/pdd && cp src/services/platforms/pdd/pdd_anti.cjs dist/services/platforms/pdd/pdd_anti.cjs",
|
|
"db:migrate": "tsx src/db/migrate.ts",
|
|
"db:migrate:create": "tsx scripts/create-migration.ts",
|
|
"db:migrate:status": "tsx scripts/migration-status.ts",
|
|
"finance:sync": "tsx scripts/sync-cost-finance.ts",
|
|
"fulfillment:backfill": "tsx scripts/backfill-fulfillment-mode.ts",
|
|
"revenue:backfill": "tsx scripts/backfill-revenue-basis.ts",
|
|
"storage:migrate": "tsx scripts/migrate-storage.ts",
|
|
"storage:migrate:built": "node dist/storage-migrate.js",
|
|
"check:sql": "tsx scripts/check-sql-guard.ts",
|
|
"dev": "tsx watch --clear-screen=false src/index.ts",
|
|
"format": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --write \"src/**/*.{ts,js,json}\" \"scripts/**/*.{ts,js}\" eslint.config.js package.json tsconfig.json tsconfig.build.json tsconfig.eslint.json",
|
|
"format:check": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --check \"src/**/*.{ts,js,json}\" \"scripts/**/*.{ts,js}\" eslint.config.js package.json tsconfig.json tsconfig.build.json tsconfig.eslint.json",
|
|
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.ts\"",
|
|
"lint:check": "npm run lint -- --quiet",
|
|
"lint:fix": "npm run lint -- --fix",
|
|
"mock:open91": "tsx scripts/mock-open91-order.ts",
|
|
"douyin-mashida:set-public-url": "tsx scripts/douyin-mashida-set-public-url.ts",
|
|
"douyin-mashida:preflight": "tsx scripts/douyin-mashida-preflight.ts",
|
|
"douyin-mashida:subscribe": "tsx scripts/douyin-mashida-subscribe.ts",
|
|
"test": "node --import tsx --test $(find src \\( -name '*.test.ts' -o -name '*.test.js' \\) -print)",
|
|
"test:industry": "tsx scripts/test-kuaishou-industry.ts",
|
|
"test:industry:http": "tsx scripts/test-kuaishou-industry-http.ts",
|
|
"test:industry:gen": "tsx scripts/gen-test-cases.ts",
|
|
"test:industry:curl": "tsx scripts/curl-send-callback.ts",
|
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
"check": "npm run format:check && npm run check:sql && npm run lint:check && npm run typecheck && npm test && npm run build",
|
|
"start": "node dist/index.js",
|
|
"start:src": "tsx src/index.ts"
|
|
},
|
|
"dependencies": {
|
|
"@alicloud/dysmsapi20170525": "^4.6.0",
|
|
"@alicloud/openapi-client": "^0.4.15",
|
|
"@alicloud/tea-util": "^1.4.11",
|
|
"@aws-sdk/client-s3": "^3.1116.0",
|
|
"express": "^5.1.0",
|
|
"multer": "^2.2.0",
|
|
"node-pg-migrate": "^8.0.4",
|
|
"pg": "^8.16.3",
|
|
"sharp": "^0.35.3"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "10.0.1",
|
|
"@types/express": "^5.0.6",
|
|
"@types/multer": "^2.2.0",
|
|
"@types/node": "^25.6.0",
|
|
"@types/pg": "^8.20.0",
|
|
"eslint": "10.8.1",
|
|
"globals": "17.11.0",
|
|
"prettier": "3.8.3",
|
|
"tsx": "^4.22.3",
|
|
"typescript": "^6.0.2",
|
|
"typescript-eslint": "8.67.0"
|
|
}
|
|
}
|