Compare commits

..

No commits in common. "d76623f59d767a3e67f46c4a27d75b89f09da9fe" and "aaca47d825c3f1924ab1ca66a30cb57b66f200e6" have entirely different histories.

5 changed files with 0 additions and 50 deletions

View File

@ -1,22 +0,0 @@
name: build
on:
push:
branches: [main, develop, 'feature/**']
tags: ['v*']
pull_request:
branches: [main, develop]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.22.0'
- run: node --version
- run: node scripts/check-migrations.mjs
- uses: actions/upload-artifact@v3
with:
name: migrations-${{ github.sha }}
path: "*.up.sql"
if-no-files-found: error

View File

@ -1,2 +0,0 @@
ALTER TABLE course DROP COLUMN start_time, DROP COLUMN content_html;
ALTER TABLE course_series DROP COLUMN price, DROP COLUMN start_time, DROP COLUMN content_html;

View File

@ -1,2 +0,0 @@
ALTER TABLE course ADD COLUMN start_time DATETIME NULL, ADD COLUMN content_html LONGTEXT NULL;
ALTER TABLE course_series ADD COLUMN price INT NULL COMMENT 'Independent series price in cents; NULL means not configured', ADD COLUMN start_time DATETIME NULL, ADD COLUMN content_html LONGTEXT NULL;

View File

@ -1,9 +0,0 @@
# 数据库迁移
这些文件是历史增量,不是完整数据库。运行全部迁移前,必须导入经授权的脱敏基础结构,至少存在 `users.teacher`;其他业务表依赖私有 dbtable 模块,也需核对。不要用虚构的 users 表冒充完整初始化。
在上级工作区运行 `./scripts/workspace.ps1 migrate`,使用隔离的本地 MySQL 和 golang-migrate 记录版本。已有数据库须先核对 schema_migrations 与实际结构;禁止盲目 force。已执行的 SQL 不修改,新变更新增时间戳文件。
`node scripts/check-migrations.mjs` 仅检查命名、版本唯一性和非空。SQL 是否可执行须在脱敏基线数据库验证。现有迁移无 down 脚本,生产回退依赖经验证的备份恢复或补偿迁移,不自动回滚。
新增 `1792400000_course_details.up.sql`:为 course 和 course_series 增加 start_time、content_html,系列增加可空独立售价 price(分)。先迁移,再部署对应 API。该版本包含 down 脚本,执行会丢失这些新字段中的数据,必须先备份。历史版本仍无 down 脚本。已在 MySQL 8 临时表验证此版本 up/down;生产完整基线仍需部署前验证。

View File

@ -1,15 +0,0 @@
import { readdirSync, readFileSync } from 'node:fs';
import assert from 'node:assert/strict';
const files = readdirSync('.').filter(f => f.endsWith('.sql')).sort();
assert(files.length > 0, 'No migrations');
const versions = new Set();
for (const file of files) {
const match = /^(\d+)_([a-z0-9_]+)\.(up|down)\.sql$/.exec(file);
assert(match, `Invalid migration filename: ${file}`);
const key = `${match[1]}:${match[3]}`;
assert(!versions.has(key), `Duplicate version and direction: ${file}`);
versions.add(key);
if (match[3] === 'down') assert(files.includes(`${match[1]}_${match[2]}.up.sql`), `Missing matching up migration: ${file}`);
assert(readFileSync(file, 'utf8').trim(), `Empty migration: ${file}`);
}
console.log(`${files.length} migration files checked (structure only; MySQL execution still required).`);