{"record":{"id":"8db746ddc9fcff4e","repo":"golang-migrate/migrate","slug":"no-schema-8db746","errorCode":null,"errorMessage":"no schema","messagePattern":"no schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/sqlserver/sqlserver.go","lineNumber":30,"sourceCode":"\t\"sync/atomic\"\n\n\t\"github.com/Azure/go-autorest/autorest/adal\"\n\t\"github.com/golang-migrate/migrate/v4\"\n\t\"github.com/golang-migrate/migrate/v4/database\"\n\tmssql \"github.com/microsoft/go-mssqldb\" // mssql support\n)\n\nfunc init() {\n\tdatabase.Register(\"sqlserver\", &SQLServer{})\n}\n\n// DefaultMigrationsTable is the name of the migrations table in the database\nvar DefaultMigrationsTable = \"schema_migrations\"\n\nvar (\n\tErrNilConfig                 = fmt.Errorf(\"no config\")\n\tErrNoDatabaseName            = fmt.Errorf(\"no database name\")\n\tErrNoSchema                  = fmt.Errorf(\"no schema\")\n\tErrDatabaseDirty             = fmt.Errorf(\"database is dirty\")\n\tErrMultipleAuthOptionsPassed = fmt.Errorf(\"both password and useMsi=true were passed\")\n)\n\nvar lockErrorMap = map[int]string{\n\t-1:   \"The lock request timed out.\",\n\t-2:   \"The lock request was canceled.\",\n\t-3:   \"The lock request was chosen as a deadlock victim.\",\n\t-999: \"Parameter validation or other call error.\",\n}\n\n// Config for database\ntype Config struct {\n\tMigrationsTable string\n\tDatabaseName    string\n\tSchemaName      string\n}\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/sqlserver/sqlserver.go#L12-L48","documentation":"Sentinel error ErrNoSchema defined in database/sqlserver/sqlserver.go. It is a generic guard indicating that no schema name was provided or resolvable when opening the driver. The same sentinel pattern exists in drivers like pgx, where Open returns it when the parsed schema name (e.g. the x-migrations-table schema component) is empty. Fix by specifying the schema in the connection URL or configuration.","triggerScenarios":"Open with a URL lacking ?schema= while Config.SchemaName is empty; WithInstance/WithConnection with a Config that has no SchemaName and no schema resolvable from the URL.","commonSituations":"Migrating a schema other than dbo without specifying it; URLs copied from other drivers (mysql/pgx variants) that don't carry a schema parameter; team conventions requiring custom schemas.","solutions":["Append &schema=<name> to the sqlserver:// URL","Set Config.SchemaName explicitly in WithInstance/WithConnection","If the default dbo schema is intended, confirm your SQL Server user resolves to dbo rather than passing an empty schema"],"exampleFix":"// before\nd, err := migrate.Open(\"sqlserver://sa:pass@localhost:1433?database=mydb\")\n// after\nd, err := migrate.Open(\"sqlserver://sa:pass@localhost:1433?database=mydb&schema=dbo\")","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dsn)\nif u.Query().Get(\"schema\") == \"\" {\n    return errors.New(\"sqlserver DSN must include schema=<name>\")\n}","typeGuard":"func hasSchema(u *url.URL) bool { return u.Query().Get(\"schema\") != \"\" }","tryCatchPattern":null,"preventionTips":["Default to schema=dbo explicitly rather than relying on server defaults","Keep one DSN template per environment including both database and schema","Document required query params for the sqlserver migrate driver"],"tags":["go","sqlserver","database","migration","missing-schema"],"backgroundTag":"missing-schema","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}