{"record":{"id":"998f3f203f8b3ef9","repo":"golang-migrate/migrate","slug":"no-schema","errorCode":null,"errorMessage":"no schema","messagePattern":"no schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/spanner/spanner.go","lineNumber":38,"sourceCode":"\t\"github.com/golang-migrate/migrate/v4/database\"\n\n\tadminpb \"cloud.google.com/go/spanner/admin/database/apiv1/databasepb\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc init() {\n\tdb := Spanner{}\n\tdatabase.Register(\"spanner\", &db)\n}\n\n// DefaultMigrationsTable is used if no custom table is specified\nconst DefaultMigrationsTable = \"SchemaMigrations\"\n\n// Driver errors\nvar (\n\tErrNilConfig      = errors.New(\"no config\")\n\tErrNoDatabaseName = errors.New(\"no database name\")\n\tErrNoSchema       = errors.New(\"no schema\")\n\tErrDatabaseDirty  = errors.New(\"database is dirty\")\n\tErrLockHeld       = errors.New(\"unable to obtain lock\")\n\tErrLockNotHeld    = errors.New(\"unable to release already released lock\")\n)\n\n// Config used for a Spanner instance\ntype Config struct {\n\tMigrationsTable string\n\tDatabaseName    string\n\t// Whether to parse the migration DDL with spansql before\n\t// running them towards Spanner.\n\t// Parsing outputs clean DDL statements such as reformatted\n\t// and void of comments.\n\tCleanStatements bool\n}\n\n// Spanner implements database.Driver for Google Cloud Spanner\ntype Spanner struct {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/spanner/spanner.go#L20-L56","documentation":"spanner.ErrNoSchema is returned by the Spanner driver's WithInstance, WithConnection, and Open when no schema name is configured. The driver uses the schema to qualify the migrations table; without it the DDL/DML it builds would be ambiguous. It signals missing or incomplete driver configuration.","triggerScenarios":"Open/WithInstance called without the schema component in the spanner URL or with an empty Config schema field; a DSN template that dropped the schema segment.","commonSituations":"Copying a DSN pattern from another driver (e.g. postgres) that did not include the schema part, env substitution leaving the schema blank, multi-schema setups where the schema config was accidentally removed.","solutions":["Include the schema in the connection string/URL so the driver can parse it.","Populate the schema field in the *spanner.Config when constructing the driver manually.","Validate the schema value (non-empty) before calling the driver."],"exampleFix":"// before\ncfg := &spanner.Config{DatabaseName: \"projects/p/instances/i/databases/d\"}\n// after\ncfg := &spanner.Config{DatabaseName: \"projects/p/instances/i/databases/d\", SchemaName: \"public\"}","handlingStrategy":"validation","validationCode":"if cfg == nil || cfg.SchemaName == \"\" {\n    return fmt.Errorf(\"spanner schema name is required to qualify the migrations table\")\n}","typeGuard":"func hasSchema(cfg *spanner.Config) bool { return cfg != nil && cfg.SchemaName != \"\" }","tryCatchPattern":"driver, err := spanner.WithInstance(client, cfg)\nif errors.Is(err, spanner.ErrNoSchema) {\n    return fmt.Errorf(\"schema missing in spanner config or URL\")\n}","preventionTips":["Include the schema in every DSN template your tooling generates.","Validate all config fields (database, schema, table) together before driver creation.","When copying driver setups between databases, re-check schema-specific fields."],"tags":["go","configuration","spanner","schema","go-migrate"],"backgroundTag":"missing-configuration","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}