feat(builtin-models): add YAML-based declarative config with ${ENV} interpolation
Allow built-in models to be declared in config/builtin_models.yaml
instead of inserting rows via SQL. On every startup the file is read
and each entry is UPSERT-ed into the models table (is_builtin=true)
by stable id.
Any string field may reference an environment variable with ${NAME}.
Unset variables are left as the literal placeholder so
misconfiguration surfaces clearly in provider calls rather than
failing silently with an empty token.
The file is optional: missing file, parse errors, and per-entry
upsert failures all log a warning without aborting startup.
docker-compose.yml adds env_file (.env, required:false) so
deployment-specific variables are passed through automatically.
This commit is contained in:
@@ -536,6 +536,11 @@ func initDatabase(cfg *config.Config) (*gorm.DB, error) {
|
||||
// The SQL migration marks KBs that have documents but no provider with "__pending_env__";
|
||||
// we replace that with the actual STORAGE_TYPE from the environment.
|
||||
resolveStorageProviderPending(db)
|
||||
|
||||
// Post-migration: declarative built-in models from config/builtin_models.yaml (optional).
|
||||
if err := types.LoadBuiltinModelsConfig(context.Background(), db, config.ConfigDir()); err != nil {
|
||||
logger.Warnf(context.Background(), "Load builtin models config failed: %v", err)
|
||||
}
|
||||
} else {
|
||||
logger.Infof(context.Background(), "Auto-migration is disabled (AUTO_MIGRATE=false)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user