Adding SYBSession to migrations.Migrate was not enough. Schema reaches an
existing database only through a version-local file; with the previous
version already recorded in sys_migration, Migrate never re-ran and the
table simply never appeared. The unit tests build a fresh database every
time, so they stayed green while the real database was missing a table —
which surfaced as "Error 1146: Table 'goauto.syb_session' doesn't exist"
on the first import attempt.
server/.gitignore was hiding these files. go-admin ignores version-local
because it is where generated local migrations land, but every GoAuto
migration belongs in version control; the existing ones had been forced
in with `git add -f`. Un-ignoring *.go there also recovers four migrations
that were never committed at all — 1786700000000 through 1786700300000,
covering the base schema, device registration, heartbeat and collection
execution. A fresh clone could not have built a working database.
Guard the class of mistake rather than just this instance:
- migrations.VerifyTables checks every model's table after migrating and
names what is missing along with the fix.
- The migrate command runs it, so the failure lands at migrate time
instead of at the first request that needs the table.
- initDB no longer discards migrateModel's error. Upstream had
`_ = migrateModel()` followed by an unconditional "初始化成功", so a
failed migration reported success and the launcher believed it.
Also records the two-step rule in Common-Changes: a new model needs both
the model registration and a new version file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
28 lines
713 B
Plaintext
28 lines
713 B
Plaintext
.idea
|
|
.vscode
|
|
*/.DS_Store
|
|
static/uploadfile
|
|
main.exe
|
|
*.exe
|
|
go-admin
|
|
go-admin.exe
|
|
temp/
|
|
vendor
|
|
config/settings.dev.yml
|
|
config/settings.dev.*.yml
|
|
config/settings.dev.*.yml.log
|
|
temp/logs
|
|
config/settings.dev.yml.log
|
|
config/settings.b.dev.yml
|
|
# go-admin 默认忽略这个目录(它原本放本地生成的迁移)。GoAuto 的迁移全部要
|
|
# 跟踪:漏提交一个版本文件,别人的数据库就少一张表,而且要到运行时才炸。
|
|
# 之前的版本文件是靠 git add -f 进来的,这条否定规则让它不再需要。
|
|
cmd/migrate/migration/version-local/*
|
|
!cmd/migrate/migration/version-local/*.go
|
|
|
|
config/settings.deva.yml
|
|
go-admin-server
|
|
CLAUDE.md
|
|
.claude/
|
|
config/settings.local.dev.yml
|