refactor: merge tenant configuration into tenant registry

This commit is contained in:
richjohnrambo
2026-09-22 16:47:40 +08:00
parent 851eca97ed
commit 85b564e2ac
22 changed files with 216 additions and 634 deletions
@@ -12,17 +12,6 @@ import (
const imTenantIDSequenceTable = "im_tenant_id_sequence"
func sharedDatabaseConfig(ctx context.Context) (dbName, dbDSN string, err error) {
row, err := imtenant.RegistryDB().GetOne(ctx, "SELECT db_name,db_dsn FROM im_tenant WHERE code='default' LIMIT 1")
if err != nil {
return "", "", gerror.Wrap(err, "获取共享业务库配置失败")
}
if row.IsEmpty() {
return "", "", gerror.New("默认商户不存在,无法确定共享业务库")
}
return row["db_name"].String(), row["db_dsn"].String(), nil
}
func ensureTenantIDSequence(ctx context.Context) error {
db := imtenant.RegistryDB()
if _, err := db.Exec(ctx, `CREATE TABLE IF NOT EXISTS im_tenant_id_sequence (