{"record":{"id":"5a5863a486fbbb5e","repo":"golang-migrate/migrate","slug":"no-schema-5a5863","errorCode":null,"errorMessage":"no schema","messagePattern":"no schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/pgx/pgx.go","lineNumber":50,"sourceCode":"func init() {\n\tdb := Postgres{}\n\tdatabase.Register(\"pgx\", &db)\n\tdatabase.Register(\"pgx4\", &db)\n}\n\nvar (\n\tmultiStmtDelimiter = []byte(\";\")\n\n\tDefaultMigrationsTable       = \"schema_migrations\"\n\tDefaultMultiStatementMaxSize = 10 * 1 << 20 // 10 MB\n\tDefaultLockTable             = \"schema_lock\"\n\tDefaultLockStrategy          = LockStrategyAdvisory\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\tDatabaseName          string\n\tSchemaName            string\n\tLockTable             string\n\tLockStrategy          string\n\tmigrationsSchemaName  string\n\tmigrationsTableName   string\n\tStatementTimeout      time.Duration\n\tMigrationsTableQuoted bool\n\tMultiStatementEnabled bool\n\tMultiStatementMaxSize int\n}\n\ntype Postgres struct {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/pgx/pgx.go#L32-L68","documentation":"ErrNoSchema means pgx could not determine the PostgreSQL schema for migrations. It is raised when config.SchemaName is empty AND the session's CURRENT_SCHEMA() returns an empty string (pgx.WithInstance line 108-110; same check in WithConnection and Open, and in pgx/v5). Normally CURRENT_SCHEMA() falls back to 'public', so this error indicates an unusual session state.","triggerScenarios":"Calling pgx.WithInstance/WithConnection/Open with an empty config.SchemaName while the connection's current schema is unset or empty — e.g. search_path cleared via options, a revoked public schema, or a stripped-down connection role.","commonSituations":"Connecting with a restricted role where public schema was dropped (Postgres 15+ default behavior change); setting search_path='' in DSN options; cloning connections in pooled environments without a search_path.","solutions":["Set config.SchemaName explicitly (e.g. \"public\" or your target schema) in the pgx.Config","Ensure the connection has a valid search_path (do not override it to empty in the DSN)","Confirm the role can access the schema and the schema exists (CREATE SCHEMA if needed)"],"exampleFix":"// before\ncfg := &pgx.Config{ DatabaseName: \"app\" } // SchemaName empty\n// after\ncfg := &pgx.Config{ DatabaseName: \"app\", SchemaName: \"public\" }","handlingStrategy":"validation","validationCode":"if cfg.SchemaName == \"\" {\n    var s string\n    if err := db.QueryRow(\"SELECT CURRENT_SCHEMA()\").Scan(&s); err != nil || s == \"\" {\n        cfg.SchemaName = \"public\" // or fail fast with a clear message\n    }\n}","typeGuard":null,"tryCatchPattern":"drv, err := pgx.WithInstance(db, cfg)\nif errors.Is(err, pgx.ErrNoSchema) {\n    return fmt.Errorf(\"no schema: set cfg.SchemaName explicitly or fix search_path: %w\", err)\n}","preventionTips":["Always set SchemaName explicitly instead of relying on CURRENT_SCHEMA()","Do not blank the search_path via DSN options","After Postgres 15 upgrades, verify the role's CREATE/USAGE privileges on the public schema"],"tags":["postgres","pgx","schema","configuration"],"backgroundTag":"missing-schema","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}