{"record":{"id":"46b0280d69fabafe","repo":"golang-migrate/migrate","slug":"no-schema-46b028","errorCode":null,"errorMessage":"no schema","messagePattern":"no schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/postgres/postgres.go","lineNumber":40,"sourceCode":")\n\nfunc init() {\n\tdb := Postgres{}\n\tdatabase.Register(\"postgres\", &db)\n\tdatabase.Register(\"postgresql\", &db)\n}\n\nvar (\n\tmultiStmtDelimiter = []byte(\";\")\n\n\tDefaultMigrationsTable       = \"schema_migrations\"\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n)\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)\n\ntype Config struct {\n\tMigrationsTable       string\n\tMigrationsTableQuoted bool\n\tMultiStatementEnabled bool\n\tDatabaseName          string\n\tSchemaName            string\n\tmigrationsSchemaName  string\n\tmigrationsTableName   string\n\tStatementTimeout      time.Duration\n\tMultiStatementMaxSize int\n}\n\ntype Postgres struct {\n\t// Locking and unlocking need to use the same connection\n\tconn     *sql.Conn","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/postgres/postgres.go#L22-L58","documentation":"ErrNoSchema is returned by the postgres-family drivers when a schema name is required but empty. For lib/pq's postgres driver, Open/WithInstance return it when x-schema-name is absent while the driver requires one; the sentinel is shared and re-declared in pgx copies.","triggerScenarios":"Calling postgres.Open with a URL missing x-schema-name when the driver instance requires a schema, or WithInstance/WithConnection with Config{SchemaName: \"\"}; the pgx variant at database/pgx/pgx.go:109 returns it when schemaName resolves to length 0.","commonSituations":"Migrating within a specific Postgres schema but forgetting the x-schema-name URL parameter; empty env var interpolation for the schema; confusing database name with schema name in the config.","solutions":["Add x-schema-name=<schema> to the connection URL, e.g. ?x-schema-name=myschema","Set Config.SchemaName in the Config struct for WithInstance/WithConnection","Use 'public' explicitly if you intended the default schema","Match with errors.Is(err, postgres.ErrNoSchema) to surface a friendly message"],"exampleFix":"// before\ndsn := \"postgres://u:p@host/db\"\n// after\ndsn := \"postgres://u:p@host/db?x-schema-name=myschema\"","handlingStrategy":"validation","validationCode":"if cfg != nil && cfg.SchemaName == \"\" {\n    return errors.New(\"Config.SchemaName must be set (use \\\"public\\\" for the default schema)\")\n}","typeGuard":null,"tryCatchPattern":"if err := m.Up(); err != nil {\n    if errors.Is(err, postgres.ErrNoSchema) {\n        log.Fatal(\"schema missing: add ?x-schema-name=<schema> to the DSN or set Config.SchemaName\")\n    }\n    panic(err)\n}","preventionTips":["Set x-schema-name in the DSN when migrations target a non-default schema","Provide 'public' explicitly rather than relying on defaults","Distinguish database name from schema name in config structs"],"tags":["configuration","missing-value","postgres","schema"],"backgroundTag":"missing-schema-name","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}