fix: auto-provision im_user_privacy_settings columns on startup

Zentao #24/#25: commit 50f8581 added friend_request_verification and group_invite_verification to userPrivacyByUID, but existing databases lack those columns, so GetPrivacy failed with Error 1054 and every cross-user profile/qrcodes/friend-request endpoint returned 500.

Add user_privacy_schema.go which, under GET_LOCK, checks information_schema and ALTERs in any missing privacy columns, wired into the root adapter Open() and per-tenant TenantAdapterFor so tenant-scoped databases are provisioned too.
This commit is contained in:
Austin
2026-09-18 10:55:13 +08:00
parent c6e7f6b923
commit 7a52db3437
2 changed files with 71 additions and 0 deletions
+7
View File
@@ -284,6 +284,9 @@ func (a *adapter) Open(jsonconfig json.RawMessage) error {
return errors.New("mysql adapter failed to open tenant registry database: " + err.Error())
}
}
if err = ensureUserPrivacySchema(a.db); err != nil {
return errors.New("mysql adapter failed to ensure user privacy schema: " + err.Error())
}
}
return err
}
@@ -494,6 +497,10 @@ func (a *adapter) TenantAdapterFor(tenantID t.TenantID) (dbadapter.TenantBusines
db.Close()
return nil, nil, err
}
if err = ensureUserPrivacySchema(db); err != nil {
db.Close()
return nil, nil, errors.New("mysql adapter failed to ensure user privacy schema for tenant: " + err.Error())
}
registryDB := a.registryDB
if registryDB == nil {
registryDB = a.db