fix(mysql): adapt tenant shared database fields

This commit is contained in:
richjohnrambo
2026-09-22 14:40:15 +08:00
parent 865b436264
commit 2e0612acbb
11 changed files with 861 additions and 528 deletions
+6 -6
View File
@@ -84,8 +84,8 @@ func TestGroupBusinessTablesCreated(t *testing.T) {
if err := db.Get(&count, query, args...); err != nil {
t.Fatal(err)
}
if count != 0 {
t.Fatalf("tenant business tables contain %d tenant_id columns", count)
if count != len(tables) {
t.Fatalf("tenant business tables with tenant_id: got %d, want %d", count, len(tables))
}
}
@@ -264,12 +264,12 @@ func TestTenantAuthIsolation(t *testing.T) {
}
}
createTenant := func(code, dbName string) types.TenantID {
res, err := db.Exec("INSERT INTO im_tenant(code,name,db_name,state,created_by,updated_by) VALUES(?,?,?,?,?,?)",
code+suffix, code, dbName, types.TenantStateActive, 0, 0)
if err != nil {
var id int64
if err := db.Get(&id, "SELECT COALESCE(MAX(id),0)+1 FROM im_tenant"); err != nil {
t.Fatal(err)
}
id, err := res.LastInsertId()
_, err := db.Exec("INSERT INTO im_tenant(id,code,name,db_name,state,created_by,updated_by) VALUES(?,?,?,?,?,?,?)",
id, code+suffix, code, dbName, types.TenantStateActive, 0, 0)
if err != nil {
t.Fatal(err)
}