chore: disable runtime mysql schema creation

This commit is contained in:
richjohnrambo
2026-09-13 13:56:24 +08:00
parent eefc3c2fbd
commit ccbd385d2f
5 changed files with 547 additions and 96 deletions
@@ -55,6 +55,66 @@ func TestMessageSearchDoesNotClearScannedHead(t *testing.T) {
}
}
func TestRuntimeOpenDoesNotAutoCreateOrMigrateTables(t *testing.T) {
source, err := os.ReadFile("adapter.go")
if err != nil {
t.Fatal(err)
}
body := string(source)
for _, tc := range []struct {
name string
function string
end string
}{
{
name: "Open",
function: "func (a *adapter) Open",
end: "\nfunc (a *adapter) Close",
},
{
name: "TenantAdapterFor",
function: "func (a *adapter) TenantAdapterFor",
end: "\nfunc (a *adapter) tenantByID",
},
} {
fn := sourceBetween(t, body, tc.function, tc.end)
for _, forbidden := range []string{
"ensureIMRegistrationInviteControlTables",
"ensureIMTenantEntryControlTables",
"ensureIMGroupBusinessTables",
"ensureIMHTTPInfrastructureTables",
"ensureIMAdminGovernanceTables",
"ensureIMFileReviewTables",
"ensureIMOrganizationVisibilityTables",
"ensureIMAttendanceTables",
"ensureIMMeetingNotesTables",
"ensureSnowflakePrimaryKeys",
"ensureUserIdentitySchema",
"ensureIMRegistrationInviteUseTable",
"CREATE DATABASE",
"CREATE TABLE",
"ALTER TABLE",
} {
if strings.Contains(fn, forbidden) {
t.Fatalf("%s must not auto-create or auto-migrate schema; found %q", tc.name, forbidden)
}
}
}
}
func sourceBetween(t *testing.T, source, startMarker, endMarker string) string {
t.Helper()
start := strings.Index(source, startMarker)
if start < 0 {
t.Fatalf("missing source marker %q", startMarker)
}
end := strings.Index(source[start:], endMarker)
if end < 0 {
t.Fatalf("missing source marker %q after %q", endMarker, startMarker)
}
return source[start : start+end]
}
func TestSearchPaginationCursorUsesLastReturnedRow(t *testing.T) {
source, err := os.ReadFile("tenant_adapter.go")
if err != nil {