feat(library): 整库发布支持 WeKnora 0.9.0 schema 134
build / build (push) Failing after 1m32s

按 schema 版本选 profile 并以 information_schema 能力探测放行,取代写死的
version==74;未知版本、脏库、缺表缺列、跨版本搬运一律拒绝并点名原因。
0.9.0 的索引名改从部署配置解析,wiki_log_entries 按 profile 变为可选,
归档部件集合随之一致。
This commit is contained in:
姚章浩
2026-11-16 20:22:29 +08:00
parent e8bfdbbc06
commit 3f2626f621
20 changed files with 1211 additions and 62 deletions
@@ -10,6 +10,8 @@ import (
"sort"
"github.com/jackc/pgx/v5"
"knowledge-governance/internal/libraryprofile"
)
var resourceReferencePattern = regexp.MustCompile(`resource://([A-Za-z0-9_-]{22})`)
@@ -30,6 +32,29 @@ type TableSnapshot struct {
type PostgresSnapshot struct {
Catalog migrationCatalog `json:"catalog,omitempty"`
Tables []TableSnapshot
// SchemaVersion 是导出/导入两侧共同的 profile 标识:归档必须与目标同版本,
// 否则行里的列语义(例如 0.9.0 新增的 NOT NULL 列)不可比。
SchemaVersion int `json:"schema_version,omitempty"`
Profile string `json:"profile,omitempty"`
}
// schemaProfile 解析快照声明的 profile。0 表示既有内存夹具(0.7.1),
// 只把"没有声明版本"解释成 74,不把未知版本解释成任何 profile。
func (snapshot PostgresSnapshot) schemaProfile() (SchemaProfile, error) {
profile, err := libraryprofile.For(snapshot.SchemaVersion)
if err != nil {
if snapshot.SchemaVersion != 0 {
return SchemaProfile{}, err
}
profile, err = libraryprofile.For(libraryprofile.LegacyVersion)
if err != nil {
return SchemaProfile{}, err
}
}
resolved := SchemaProfile{Profile: profile}
resolved.Tables = append(resolved.Tables, profile.RequiredTables...)
resolved.Tables = append(resolved.Tables, profile.OptionalTables...)
return resolved, nil
}
func (snapshot PostgresSnapshot) Table(name string) TableSnapshot {