Compare commits

...

2 Commits

Author SHA1 Message Date
Codex 2715405c7d docs(M01-B): 记录迁移执行与兼容查询进度 2026-06-18 09:32:45 +08:00
Codex e069c50331 feat(M01-B): 增加迁移执行器与旧库只读兼容层 2026-06-18 09:31:29 +08:00
13 changed files with 512 additions and 12 deletions
+2 -2
View File
@@ -113,8 +113,8 @@ WSL 已验证:EMQX `5.8.9`、MQTTX CLI `1.13.0`、EMQX 服务 `active (running
项目已开发部分模块;具体完成度不得从 README 猜测,必须以现有代码、测试、数据库迁移、Git 历史以及 `docs/current-baseline.md``docs/module-status.md``docs/feature-status.md` 为准。
- 最近工程提交:`3add64b fix(M01-B): 避免连接池凭据误触秘密扫描`
- 下一工程目标:以 `docs/current-baseline.md``next_engineering_target` 为准,当前为 M01-B 迁移执行器、MySQL dry-run 与旧表兼容 Repository
- 最近工程提交:`e069c50 feat(M01-B): 增加迁移执行器与旧库只读兼容层`
- 下一工程目标:以 `docs/current-baseline.md``next_engineering_target` 为准,当前为 M01-B 一次性 MySQL 往返迁移验证与旧 DECIMAL 金额边界转换
- 开发纪律:普通“继续开发”必须产生工程文件变化、测试、commit 和 push;只改 Markdown 不计入模块进度。
## 版本递进
+5 -1
View File
@@ -11,7 +11,11 @@
"dev": "tsx watch src/server.ts",
"build": "tsc -p tsconfig.json",
"start": "node dist/server.js",
"test": "npm run build && node tests/backend-contract.test.mjs && node tests/migration-contract.test.mjs && node tests/mysql-pool-contract.test.mjs"
"db:migrate:plan": "npm run build && node dist/db/migrate-cli.js plan",
"db:migrate:up": "npm run build && node dist/db/migrate-cli.js up",
"db:migrate:verify": "npm run build && node dist/db/migrate-cli.js verify",
"db:migrate:down": "npm run build && node dist/db/migrate-cli.js down",
"test": "npm run build && node tests/backend-contract.test.mjs && node tests/migration-contract.test.mjs && node tests/mysql-pool-contract.test.mjs && node tests/migration-runner.test.mjs && node tests/legacy-read-repository.test.mjs"
},
"dependencies": {
"@fastify/cors": "^11.2.0",
+145
View File
@@ -0,0 +1,145 @@
import type { MySqlPool } from './mysql.js';
type LegacyEntity = 'stores' | 'rooms' | 'orders' | 'devices';
export interface LegacyTableMapping {
table: string;
idColumn: string;
tenantColumn: string;
parentColumn?: string;
nameColumn?: string;
statusColumn?: string;
codeColumn?: string;
startColumn?: string;
endColumn?: string;
}
export interface LegacyReadOptions {
tenantId: number;
parentId?: number;
limit?: number;
}
export interface LegacyRecord {
legacyId: string;
tenantId: string;
parentId: string | null;
name: string | null;
code: string | null;
status: string | null;
startAt: Date | string | null;
endAt: Date | string | null;
}
export const defaultLegacyMappings: Record<LegacyEntity, LegacyTableMapping> = {
stores: {
table: 'member_store_info',
idColumn: 'id',
tenantColumn: 'tenant_id',
nameColumn: 'store_name',
statusColumn: 'status'
},
rooms: {
table: 'member_room_info',
idColumn: 'id',
tenantColumn: 'tenant_id',
parentColumn: 'store_id',
nameColumn: 'room_name',
codeColumn: 'room_no',
statusColumn: 'status'
},
orders: {
table: 'member_order_info',
idColumn: 'id',
tenantColumn: 'tenant_id',
parentColumn: 'room_id',
codeColumn: 'order_no',
statusColumn: 'status',
startColumn: 'start_time',
endColumn: 'end_time'
},
devices: {
table: 'member_device_info',
idColumn: 'id',
tenantColumn: 'tenant_id',
parentColumn: 'room_id',
nameColumn: 'device_name',
codeColumn: 'device_id',
statusColumn: 'status'
}
};
const identifierPattern = /^[A-Za-z][A-Za-z0-9_]*$/;
function quoteIdentifier(identifier: string): string {
if (!identifierPattern.test(identifier)) {
throw new Error(`Unsafe legacy SQL identifier: ${identifier}`);
}
return `\`${identifier}\``;
}
function selectedColumn(column: string | undefined, alias: string): string {
return column ? `${quoteIdentifier(column)} AS ${quoteIdentifier(alias)}` : `NULL AS ${quoteIdentifier(alias)}`;
}
function normalizeLimit(limit = 100): number {
if (!Number.isInteger(limit) || limit < 1 || limit > 500) {
throw new Error('Legacy read limit must be an integer between 1 and 500.');
}
return limit;
}
export class LegacyReadRepository {
constructor(
private readonly pool: Pick<MySqlPool, 'query'>,
private readonly mappings: Record<LegacyEntity, LegacyTableMapping> = defaultLegacyMappings
) {}
listStores(options: LegacyReadOptions): Promise<LegacyRecord[]> {
return this.list('stores', options);
}
listRooms(options: LegacyReadOptions): Promise<LegacyRecord[]> {
return this.list('rooms', options);
}
listOrders(options: LegacyReadOptions): Promise<LegacyRecord[]> {
return this.list('orders', options);
}
listDevices(options: LegacyReadOptions): Promise<LegacyRecord[]> {
return this.list('devices', options);
}
private async list(entity: LegacyEntity, options: LegacyReadOptions): Promise<LegacyRecord[]> {
const mapping = this.mappings[entity];
const limit = normalizeLimit(options.limit);
const clauses = [`${quoteIdentifier(mapping.tenantColumn)} = ?`];
const parameters: Array<number> = [options.tenantId];
if (mapping.parentColumn && options.parentId !== undefined) {
clauses.push(`${quoteIdentifier(mapping.parentColumn)} = ?`);
parameters.push(options.parentId);
}
parameters.push(limit);
const sql = [
'SELECT',
`${quoteIdentifier(mapping.idColumn)} AS ${quoteIdentifier('legacyId')},`,
`${quoteIdentifier(mapping.tenantColumn)} AS ${quoteIdentifier('tenantId')},`,
`${selectedColumn(mapping.parentColumn, 'parentId')},`,
`${selectedColumn(mapping.nameColumn, 'name')},`,
`${selectedColumn(mapping.codeColumn, 'code')},`,
`${selectedColumn(mapping.statusColumn, 'status')},`,
`${selectedColumn(mapping.startColumn, 'startAt')},`,
selectedColumn(mapping.endColumn, 'endAt'),
`FROM ${quoteIdentifier(mapping.table)}`,
`WHERE ${clauses.join(' AND ')}`,
`ORDER BY ${quoteIdentifier(mapping.idColumn)} ASC`,
'LIMIT ?'
].join(' ');
const [rows] = await this.pool.query(sql, parameters);
return rows as LegacyRecord[];
}
}
+49
View File
@@ -0,0 +1,49 @@
import { loadConfig } from '../config.js';
import { closeMySqlPool, createMySqlPool } from './mysql.js';
import {
executeMigrationPlan,
loadMigrationPlan,
type MigrationDirection
} from './migration-runner.js';
const command = process.argv[2] ?? 'plan';
const validCommands = new Set(['plan', 'up', 'verify', 'down']);
if (!validCommands.has(command)) {
console.error('Usage: migrate-cli.js <plan|up|verify|down>');
process.exitCode = 2;
} else {
const direction: MigrationDirection = command === 'plan' ? 'up' : command as MigrationDirection;
const plan = await loadMigrationPlan(direction);
if (command === 'plan') {
console.log(JSON.stringify({
mode: 'dry-run',
direction: plan.direction,
file: plan.file,
checksum: plan.checksum,
statementCount: plan.statements.length
}, null, 2));
} else {
const config = loadConfig();
if (!config.mysql.passwordConfigured) {
console.error('QIPAI_MYSQL_PASSWORD is required for live migration commands.');
process.exitCode = 2;
} else {
const pool = createMySqlPool(config);
try {
const result = await executeMigrationPlan(pool, plan);
console.log(JSON.stringify({
mode: 'live',
direction: result.direction,
file: result.file,
checksum: result.checksum,
statementCount: result.statements.length,
affectedRows: result.affectedRows
}, null, 2));
} finally {
await closeMySqlPool(pool);
}
}
}
}
+153
View File
@@ -0,0 +1,153 @@
import { createHash } from 'node:crypto';
import { readFile } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { MySqlPool } from './mysql.js';
export type MigrationDirection = 'up' | 'verify' | 'down';
export interface MigrationPlan {
direction: MigrationDirection;
file: string;
checksum: string;
statements: readonly string[];
}
export interface MigrationExecutionResult extends MigrationPlan {
executed: boolean;
affectedRows: number;
}
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../..');
const migrationFiles: Record<MigrationDirection, string> = {
up: 'database/migrations/2026061601_m01b_core_schema.up.sql',
verify: 'database/migrations/2026061601_m01b_core_schema.verify.sql',
down: 'database/migrations/2026061601_m01b_core_schema.down.sql'
};
export function splitSqlStatements(sql: string): string[] {
const statements: string[] = [];
let current = '';
let quote: "'" | '"' | '`' | null = null;
let escaped = false;
let lineComment = false;
let blockComment = false;
for (let index = 0; index < sql.length; index += 1) {
const character = sql[index];
const next = sql[index + 1];
if (lineComment) {
if (character === '\n') {
lineComment = false;
current += character;
}
continue;
}
if (blockComment) {
if (character === '*' && next === '/') {
blockComment = false;
index += 1;
}
continue;
}
if (!quote && character === '-' && next === '-' && (index === 0 || /\s/.test(sql[index - 1]))) {
lineComment = true;
index += 1;
continue;
}
if (!quote && character === '/' && next === '*') {
blockComment = true;
index += 1;
continue;
}
current += character;
if (quote) {
if (escaped) {
escaped = false;
} else if (character === '\\') {
escaped = true;
} else if (character === quote) {
if (next === quote) {
current += next;
index += 1;
} else {
quote = null;
}
}
continue;
}
if (character === "'" || character === '"' || character === '`') {
quote = character;
continue;
}
if (character === ';') {
const statement = current.slice(0, -1).trim();
if (statement) {
statements.push(statement);
}
current = '';
}
}
const trailing = current.trim();
if (trailing) {
statements.push(trailing);
}
if (quote || blockComment) {
throw new Error('Migration SQL contains an unterminated quote or comment.');
}
return statements;
}
export async function loadMigrationPlan(direction: MigrationDirection): Promise<MigrationPlan> {
const relativeFile = migrationFiles[direction];
const sql = await readFile(resolve(repoRoot, relativeFile), 'utf8');
return {
direction,
file: relativeFile,
checksum: createHash('sha256').update(sql).digest('hex'),
statements: splitSqlStatements(sql)
};
}
export async function executeMigrationPlan(
pool: Pick<MySqlPool, 'query'>,
plan: MigrationPlan,
dryRun = false
): Promise<MigrationExecutionResult> {
if (dryRun) {
return { ...plan, executed: false, affectedRows: 0 };
}
let affectedRows = 0;
for (const [index, statement] of plan.statements.entries()) {
const [result] = await pool.query(statement);
if (plan.direction === 'verify') {
const minimumRows = [10, 26, 1][index] ?? 1;
if (!Array.isArray(result) || result.length < minimumRows) {
throw new Error(
`Migration verification statement ${index + 1} returned fewer than ${minimumRows} rows.`
);
}
}
if (result && typeof result === 'object' && 'affectedRows' in result) {
const value = Reflect.get(result, 'affectedRows');
if (typeof value === 'number') {
affectedRows += value;
}
}
}
return { ...plan, executed: true, affectedRows };
}
+4
View File
@@ -23,3 +23,7 @@ export function toPoolOptions(config: AppConfig): PoolOptions {
dateStrings: false
};
}
export async function closeMySqlPool(pool: MySqlPool): Promise<void> {
await pool.end();
}
@@ -0,0 +1,66 @@
import assert from 'node:assert/strict';
import { LegacyReadRepository } from '../dist/db/legacy-read-repository.js';
const calls = [];
const fakePool = {
async query(sql, parameters) {
calls.push({ sql, parameters });
return [[{
legacyId: '7',
tenantId: '2',
parentId: '3',
name: 'Room A',
code: 'A01',
status: 'OPEN',
startAt: null,
endAt: null
}], []];
}
};
const repository = new LegacyReadRepository(fakePool);
const rooms = await repository.listRooms({ tenantId: 2, parentId: 3, limit: 25 });
assert.equal(rooms.length, 1);
assert.equal(calls.length, 1);
assert.match(calls[0].sql, /FROM `member_room_info`/);
assert.match(calls[0].sql, /`tenant_id` = \?/);
assert.match(calls[0].sql, /`store_id` = \?/);
assert.match(calls[0].sql, /ORDER BY `id` ASC LIMIT \?/);
assert.deepEqual(calls[0].parameters, [2, 3, 25]);
assert.doesNotMatch(calls[0].sql, /\b(?:INSERT|UPDATE|DELETE|REPLACE)\b/i);
await assert.rejects(
() => repository.listStores({ tenantId: 2, limit: 501 }),
/between 1 and 500/
);
const unsafeRepository = new LegacyReadRepository(fakePool, {
stores: {
table: 'member_store_info; DROP TABLE users',
idColumn: 'id',
tenantColumn: 'tenant_id'
},
rooms: {
table: 'member_room_info',
idColumn: 'id',
tenantColumn: 'tenant_id'
},
orders: {
table: 'member_order_info',
idColumn: 'id',
tenantColumn: 'tenant_id'
},
devices: {
table: 'member_device_info',
idColumn: 'id',
tenantColumn: 'tenant_id'
}
});
await assert.rejects(
() => unsafeRepository.listStores({ tenantId: 2 }),
/Unsafe legacy SQL identifier/
);
console.log('PASS: legacy read-only repository contracts are present.');
+55
View File
@@ -0,0 +1,55 @@
import assert from 'node:assert/strict';
import {
executeMigrationPlan,
loadMigrationPlan,
splitSqlStatements
} from '../dist/db/migration-runner.js';
assert.deepEqual(
splitSqlStatements("SELECT 'a;b'; -- comment\nSELECT `semi;colon`;"),
["SELECT 'a;b'", 'SELECT `semi;colon`']
);
const plan = await loadMigrationPlan('up');
assert.equal(plan.direction, 'up');
assert.match(plan.file, /2026061601_m01b_core_schema\.up\.sql$/);
assert.match(plan.checksum, /^[a-f0-9]{64}$/);
assert.ok(plan.statements.length >= 11);
const calls = [];
const fakePool = {
async query(sql) {
calls.push(sql);
return [{ affectedRows: 1 }, []];
}
};
const dryRun = await executeMigrationPlan(fakePool, plan, true);
assert.equal(dryRun.executed, false);
assert.equal(calls.length, 0);
const liveResult = await executeMigrationPlan(fakePool, {
direction: 'up',
file: 'test.sql',
checksum: 'test',
statements: ['SELECT 1', 'SELECT 2']
});
assert.equal(liveResult.executed, true);
assert.equal(liveResult.affectedRows, 2);
assert.deepEqual(calls, ['SELECT 1', 'SELECT 2']);
await assert.rejects(
() => executeMigrationPlan({
async query() {
return [[], []];
}
}, {
direction: 'verify',
file: 'verify.sql',
checksum: 'test',
statements: ['SELECT table_name']
}),
/returned fewer than 10 rows/
);
console.log('PASS: migration runner plan, parser and execution contracts are present.');
+7 -7
View File
@@ -1,8 +1,8 @@
# 当前开发成果基线
> V5.0 首次核验日期:2026-06-16
> audited_commit: `3add64b`
> next_engineering_target: M01-B 迁移执行器、MySQL dry-run 与旧表兼容 Repository
> audited_commit: `e069c50`
> next_engineering_target: M01-B 在一次性 MySQL 中执行 up/verify/down,并补旧 DECIMAL 金额边界转换
> 事实源:当前工作区、Git 历史、状态文档、Windows/WSL 检查脚本。
## 总体结论
@@ -11,10 +11,10 @@
|---|---|---|---|
| 总纲版本 | V5.2 已成为当前权威总纲,V5.1/V5.0/V4.8 已保留为历史备份 | 根目录存在 `V5.2.md``V5.1.md``V5.0.md``V4.8.md` | 可继续按 V5.2 开发 |
| Git 远端 | `origin=ssh://git@git.txyundm.cn:2222/panda/qipai.git`,分支 `main` | `git rev-list main...origin/main``0 0` | 本地与远端同步 |
| 正式后端 | 已新增 Fastify 5 + TypeScript 最小骨架、健康/就绪/版本路由、配置模板、依赖锁文件、契约测试、TypeScript 编译、真实 HTTP 健康检查MySQL 连接池工厂 | `backend/package.json``backend/package-lock.json``backend/src/**``backend/tests/backend-contract.test.mjs``backend/tests/mysql-pool-contract.test.mjs``scripts/dev/windows/check-backend.ps1` | M01-B PARTIAL;真实 MySQL 执行、旧表兼容 Repository、鉴权业务接口和生产域名验收未完成 |
| 正式后端 | 已新增 Fastify 5 + TypeScript 最小骨架、健康/就绪/版本路由、配置模板、依赖锁文件、契约测试、TypeScript 编译、真实 HTTP 健康检查MySQL 连接池、迁移 CLI 和旧表只读兼容 Repository | `backend/package.json``backend/package-lock.json``backend/src/**``backend/tests/**``scripts/dev/windows/check-backend.ps1` | M01-B PARTIAL迁移 plan、SQL 拆分、执行和 verify 结果门禁已实现,旧表门店/房间/订单/设备只读查询已提供;一次性真实 MySQL 执行、旧 DECIMAL 转整数分、鉴权业务接口未完成 |
| 后台管理端 | 仅有 `admin/.gitkeep` | 当前文件扫描 | M09 未开始,不能标记 DONE |
| 微信小程序 | 仅有 `miniapp/.gitkeep` | 当前文件扫描 | M08 未开始,不能标记 DONE |
| 数据库迁移 | 已新增 M01-B 核心 schema up/down/verify SQL最小脱敏 seed | `database/migrations/2026061601_m01b_core_schema.*.sql``database/seeds/2026061601_m01b_minimal_seed.sql``backend/tests/migration-contract.test.mjs` | PARTIAL尚未连接真实 MySQL 执行迁移,旧数据迁移脚本未生成 |
| 数据库迁移 | 已新增 M01-B 核心 schema up/down/verify SQL最小脱敏 seed、迁移计划/执行 CLI 和验证结果数量门禁 | `database/migrations/2026061601_m01b_core_schema.*.sql``database/seeds/2026061601_m01b_minimal_seed.sql``backend/src/db/migration-runner.ts``backend/src/db/migrate-cli.ts` | PARTIALdry-run 已验证 11 条 up 语句和 SHA-256尚未连接一次性真实 MySQL 执行 up/verify/down,旧数据写入迁移脚本未生成 |
| M00 部署脚本 | 已有菜单、状态、HTTPS、Certbot、EMQX、备份检查模板 | `setup.sh``scripts/setup/``deploy/` | PARTIAL,生产未执行 |
| 发布清单 dry-run | 可基于当前 HEAD 输出 `deployed=false` 的 release manifest,记录后端/后台/迁移尚未生成而跳过 | `scripts/setup/deploy-business.sh --dry-run .``scripts/dev/windows/check-release-manifest.ps1` | 可在 M00 验证结构;真实构建与生产发布待 M01/M09 后接入 |
| 参考资料 | 已有清单、脱敏日志、页面/接口/表结构摘要 | `docs/reference-*``docs/db-schema-inventory.md` | PARTIAL,仍需按模块迁移正式实现 |
@@ -35,7 +35,7 @@
## 下一步
1. 继续 M01-B实现迁移执行器或 MySQL dry-run 环境,验证 up/down/verify SQL 可执行
2. 建立旧表兼容 Repository 的第一批只读查询,覆盖门店、房间、订单和设备映射
1. 继续 M01-B在一次性 MySQL 8 环境实际执行 up、verify、down,再次 up 并保存可复现结果
2. 旧表兼容 Repository 边界补充旧 DECIMAL 金额到整数分的严格转换与异常测试
3. 评估 Kysely 安全修复版的 Node 22 要求;未升级运行时前继续使用 `mysql2/promise`
4. 保持 `scripts/dev/windows/check-backend.ps1` 的契约测试、迁移契约、连接池契约、编译和 HTTP 健康检查作为 M01 后续提交门禁。
4. 保持 `scripts/dev/windows/check-backend.ps1` 的契约测试、迁移计划、编译和 HTTP 健康检查作为 M01 后续提交门禁。
@@ -78,3 +78,17 @@ release manifest dry-run 已能记录 `databaseMigration=PROJECT_PRESENT_MIGRATI
- push 时间:2026-06-16
- HEAD 与 origin/main 是否一致:本轮最终推送后复核
- 失败原因与重试命令:无
## 12. 2026-06-18 续开发:迁移执行器与旧库只读兼容层
- 新增迁移 SQL 拆分器、SHA-256 计划摘要和 `plan/up/verify/down` CLI;计划模式不连接数据库。
- `verify` 不再以“查询未报错”作为成功条件,会检查核心表、租户/审计列和迁移版本的最少结果行数。
- 新增旧表只读兼容 Repository,首批覆盖 `member_store_info``member_room_info``member_order_info``member_device_info`
- 旧表查询强制租户过滤、参数化父级过滤、1–500 条分页上限和 SQL 标识符白名单,不提供写操作。
- `npm test`:通过,新增迁移解析/执行与旧库 Repository 契约测试。
- `npm run db:migrate:plan`:通过,识别 11 条 up 语句,摘要为 `7e1e0b690aab5a99bbe32f80879621f512b04909c57c0ab26cddda4961ddd5de`
- `scripts/dev/windows/check-backend.ps1`:通过,包含编译、全部契约测试、迁移 dry-run 和真实 HTTP 健康检查。
- `scripts/dev/windows/check-secrets.ps1`:通过。
- 工程提交:`e069c50 feat(M01-B): 增加迁移执行器与旧库只读兼容层`
- 未执行真实 MySQL up/verify/down:当前工作区未配置可丢弃测试库凭据,M01-B 保持 `PARTIAL`
- 下一步:在一次性 MySQL 8 环境往返执行迁移,并实现旧 DECIMAL 金额到整数分的严格转换。
+1 -1
View File
@@ -8,7 +8,7 @@
| REF-001 | 参考资料完整纳管 | M00-A | PARTIAL | `7bb4338` | 已生成哈希清单、脱敏日志、页面地图、接口线索和旧数据库结构清单;含秘密/依赖/真实数据风险的原始包和 SQL 已移出 Git 跟踪;仓库完整性门禁已覆盖意外 untracked、嵌套 Git 和 forbidden tracked 文件。 | 后续仍需按模块生成正式源码/迁移,旧 xjar 需大文件策略。 | 进入 M00-B/M00-C 前继续保持原包忽略和摘要可追溯。 |
| SCM-001 | 模块完成即完整推送 | M00-B/M00-C | PARTIAL | `ef0edda` | 首次 main push 成功,`HEAD == origin/main` 校验通过;推送脚本已生成;仓库完整性脚本已升级为提交前门禁并接入 `test-all.ps1``push-module.ps1` 已改为先暂存显式路径再运行门禁;状态文档枚举和临时占位检查已接入。 | 后续模块仍需逐次执行并记录。 | 继续在每轮提交前执行完整性、敏感信息、大文件、状态文档和远端一致性检查。 |
| WSL-001 | WSL 隔离辅助验证 | M00-C | PARTIAL | `a690e85` | WSL 基础脚本已执行通过;本地 MQTT 服务级核验通过;认证/ACL 冒烟脚本入口、配置自检、可选 TLS/遗嘱/重复消息探测入口已生成;V5.0 点名的 WSL EMQX 检查/启动/停止入口已补齐。 | 正式后端/后台尚未生成,无法执行完整 Linux 构建;MQTT 本地账号未配置,认证/ACL/TLS/遗嘱/幂等未验收;生产 EMQX 不由 WSL 脚本管理。 | M01/M09 生成项目后在 WSL 原生临时副本执行完整构建;配置本地 MQTT 最小权限账号后执行冒烟和可选探测。 |
| API-001 | 固定 HTTPS API 域名 | M00-E/M01/M08/M10 | PARTIAL | `3add64b` | 已新增 Windows 检查脚本、Ubuntu 菜单检查和固定域名 Nginx 模板;M01-A 已通过 `/app-api/health``/admin-api/health` 源码契约、TypeScript 编译和本地真实 HTTP 请求检查;M01-B 已新增 MySQL 连接池工厂、核心迁移契约测试秘密扫描和生产依赖审计 0 漏洞。 | DNS/HTTPS 生产验证未执行,生产 Node 20+ 环境未验收,真实 MySQL 迁移执行、业务接口和鉴权未接入。 | 继续 M01-B 迁移执行器和旧表兼容 Repository;后续在 M10 接入生产域名、证书和 Nginx 真实验收。 |
| API-001 | 固定 HTTPS API 域名 | M00-E/M01/M08/M10 | PARTIAL | `e069c50` | 已新增 Windows 检查脚本、Ubuntu 菜单检查和固定域名 Nginx 模板;M01-A 已通过 `/app-api/health``/admin-api/health` 源码契约、TypeScript 编译和本地真实 HTTP 请求检查;M01-B 已新增 MySQL 连接池、迁移 CLI/dry-run/verify 门禁和旧表只读兼容 Repository,相关契约测试秘密扫描通过。 | DNS/HTTPS 生产验证未执行,当前 Windows Node 为 18、生产 Node 20+ 环境未验收,一次性真实 MySQL 往返迁移、业务接口和鉴权未接入。 | 继续 M01-B 真实 MySQL up/verify/down 与旧金额转换;后续在 M10 接入生产域名、证书和 Nginx 真实验收。 |
| TLS-001 | Nginx 与证书自动化 | M00-E/M10 | PARTIAL | `4cb3ab6` | 已生成 Nginx 模板、Certbot 命令说明和菜单第 4 项检查,可检查模板、站点启用、TLS、健康端点、证书文件、续期配置和 `certbot.timer`。 | 证书申请/续期 dry-run、80/443 生产验证未执行。 | 在生产 Ubuntu 执行证书签发、续期 dry-run 和 Nginx 安装记录。 |
| WXNET-001 | 微信合法域名与真机验证 | M00-E/M08/M10 | TODO | - | 已补 API 域名报告入口,但未做微信后台或真机验证。 | 微信后台/真机未验证。 | 后续导入小程序后执行合法域名和真机验证。 |
| OPS-001 | 固定 `/opt/apps` 目录 | M00-D/M10 | PARTIAL | `292ab7f` | `scripts/setup/init-layout.sh` 已生成目录布局、uploads 目录和 manifestWSL 检查脚本通过,未在生产 Ubuntu 执行。 | 生产操作未执行。 | 由管理员在 Ubuntu 菜单执行并记录结果。 |
+1 -1
View File
@@ -3,7 +3,7 @@
| 模块 | 状态 | 最近提交 | 最近开发日志 | 备注 |
|---|---|---|---|---|
| M00 单仓库与服务器基础骨架 | PARTIAL | `ef0edda` | docs/devlogs/2026-06-16-M00-V5-基线核验.md | V5.2 已接入;已有成果基线、仓库完整性门禁、状态文档门禁、显式路径模块推送脚本、release manifest dry-run 检查、WSL 本地 MQTT 服务级核验、认证/ACL 冒烟入口、配置自检、可选 TLS/遗嘱/重复消息探测入口和 WSL EMQX 检查/启动/停止入口已补;生产部署、账号配置、真实验收仍未完成。 |
| M01 后端 API 基础工程 | PARTIAL | `3add64b` | docs/devlogs/2026-06-16-M01-B-数据库迁移与兼容层.md | M01-A Fastify 5 + TypeScript 后端骨架、依赖锁定、生产依赖审计、TypeScript 编译和真实 HTTP 健康检查已通过;M01-B 已新增核心 schema up/down/verify SQL、最小 seed、迁移契约测试和 MySQL 连接池工厂,并通过秘密扫描;真实 MySQL 执行、旧表兼容 Repository、鉴权业务接口和生产域名验收仍未完成。 |
| M01 后端 API 基础工程 | PARTIAL | `e069c50` | docs/devlogs/2026-06-16-M01-B-数据库迁移与兼容层.md | M01-A Fastify 5 + TypeScript 后端骨架、依赖锁定、编译和真实 HTTP 健康检查已通过;M01-B 已新增核心 schema、MySQL 连接池、迁移 plan/up/verify/down CLI、verify 结果门禁和门店/房间/订单/设备旧表只读兼容 Repository。一次性真实 MySQL 往返执行、旧 DECIMAL 金额转换、鉴权业务接口仍未完成。 |
| M02 登录、租户、权限 | TODO | - | - | - |
| M03 门店、房间、价格、营业时间 | TODO | - | - | - |
| M04 订单、时段锁定、支付闭环 | TODO | - | - | - |
+10
View File
@@ -8,11 +8,16 @@ $requiredFiles = @(
"backend/src/app.ts",
"backend/src/config.ts",
"backend/src/db/mysql.ts",
"backend/src/db/migration-runner.ts",
"backend/src/db/migrate-cli.ts",
"backend/src/db/legacy-read-repository.ts",
"backend/src/routes/health.ts",
"backend/src/server.ts",
"backend/tests/backend-contract.test.mjs",
"backend/tests/migration-contract.test.mjs",
"backend/tests/mysql-pool-contract.test.mjs",
"backend/tests/migration-runner.test.mjs",
"backend/tests/legacy-read-repository.test.mjs",
"database/migrations/2026061601_m01b_core_schema.up.sql",
"database/migrations/2026061601_m01b_core_schema.down.sql",
"database/migrations/2026061601_m01b_core_schema.verify.sql",
@@ -36,6 +41,11 @@ if ($LASTEXITCODE -ne 0) {
throw "backend build failed"
}
& npm --prefix backend run db:migrate:plan
if ($LASTEXITCODE -ne 0) {
throw "backend migration dry-run failed"
}
$oldHost = $env:QIPAI_API_HOST
$oldPort = $env:QIPAI_API_PORT
$oldVersion = $env:QIPAI_API_VERSION