Files
ai_academy/internal/database/migration_versions_test.go
T
runny 7ec21f35b0 chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、
Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。
今日开发的培训推送管理改动随后单独提交。
2026-11-16 18:12:23 +08:00

25 lines
871 B
Go

package database
import (
"path/filepath"
"testing"
"github.com/golang-migrate/migrate/v4/source"
_ "github.com/golang-migrate/migrate/v4/source/file"
"github.com/stretchr/testify/require"
)
// Two pull requests that each take the next migration number both pass their
// own checks and collide once both are merged: golang-migrate refuses to load
// a directory with a duplicate version, so every deployment fails to migrate.
// 000104 did exactly that. Loading each directory catches it, since pull
// request CI runs on the merge with the current main.
func TestMigrationDirectoriesLoad(t *testing.T) {
root := sqliteRepoRoot(t)
for _, dir := range []string{"versioned", "sqlite"} {
src, err := source.Open("file://" + filepath.Join(root, "migrations", dir))
require.NoError(t, err, "migrations/%s must load", dir)
require.NoError(t, src.Close())
}
}