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
+37
View File
@@ -0,0 +1,37 @@
//go:build mysql
// +build mysql
package mysql
import (
"fmt"
t "github.com/tinode/chat/server/store/types"
)
func tenantFriendshipsTable(t.TenantID) string {
return "im_friendships"
}
func tenantMessagesTable(t.TenantID) string {
return "im_messages"
}
func tenantGroupMessagesTable(_ t.TenantID, month string) (string, bool) {
if !validShardMonth(month) {
return "", false
}
return fmt.Sprintf("im_group_messages_%s", month), true
}
func validShardMonth(month string) bool {
if len(month) != 6 {
return false
}
for i := range month {
if month[i] < '0' || month[i] > '9' {
return false
}
}
return month[4:] >= "01" && month[4:] <= "12"
}