{"record":{"id":"27b691b0cc8c6aca","repo":"golang-migrate/migrate","slug":"s-migrationstable-contains-too-many-dot-charact-27b691","errorCode":null,"errorMessage":"\"%s\" MigrationsTable contains too many dot characters","messagePattern":"\"(.+?)\" MigrationsTable contains too many dot characters","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/pgx/v5/pgx.go","lineNumber":116,"sourceCode":"\t\t}\n\n\t\tconfig.SchemaName = schemaName\n\t}\n\n\tif len(config.MigrationsTable) == 0 {\n\t\tconfig.MigrationsTable = DefaultMigrationsTable\n\t}\n\n\tconfig.migrationsSchemaName = config.SchemaName\n\tconfig.migrationsTableName = config.MigrationsTable\n\tif config.MigrationsTableQuoted {\n\t\tre := regexp.MustCompile(`\"(.*?)\"`)\n\t\tresult := re.FindAllStringSubmatch(config.MigrationsTable, -1)\n\t\tconfig.migrationsTableName = result[len(result)-1][1]\n\t\tif len(result) == 2 {\n\t\t\tconfig.migrationsSchemaName = result[0][1]\n\t\t} else if len(result) > 2 {\n\t\t\treturn nil, fmt.Errorf(\"\\\"%s\\\" MigrationsTable contains too many dot characters\", config.MigrationsTable)\n\t\t}\n\t}\n\n\tconn, err := instance.Conn(context.Background())\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpx := &Postgres{\n\t\tconn:   conn,\n\t\tdb:     instance,\n\t\tconfig: config,\n\t}\n\n\tif err := px.ensureVersionTable(); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/pgx/v5/pgx.go#L98-L134","documentation":"When Config.MigrationsTable is quoted (contains double-quoted identifiers per the quoting convention), pgx v5's WithInstance parses it with the regex `\"(.*?)\"` and accepts at most two matches: schema name plus table name. If more than two quoted segments are found — i.e. the value contains too many dot-separated quoted parts — WithInstance returns this error because a migrations table can only be schema-qualified one level deep.","triggerScenarios":"Passing Config{MigrationsTable: `\"a\".\"b\".\"c\"`} (three quoted parts) to pgxv5.WithInstance, or a value with stray quoted segments such as `\"weird\"\"name\".\"tbl\"` producing three regex matches; also reachable via Open when it delegates to WithInstance.","commonSituations":"Misunderstanding the quoting format and quoting each dot separately (\"a\".\".\".\"b\"); copying a fully-qualified name including database/catalog (db.schema.table) from pg_admin and quoting all three parts; programmatic generation of table names that joins too many quoted identifiers.","solutions":["Use at most two quoted segments: \"schema\".\"table\" — drop the database/catalog part.","If the table lives in the default schema, use a single quoted segment: \"table\".","Log the exact MigrationsTable string and count the quoted groups before calling WithInstance.","Validate in your config loader that strings.Matches of `\"(.*?)\"` number 1 or 2."],"exampleFix":"// before\ncfg.MigrationsTable = `\"mydb\".\"myschema\".\"schema_migrations\"` // 3 parts\n// after\ncfg.MigrationsTable = `\"myschema\".\"schema_migrations\"`","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`\"(.*?)\"`)\nif n := len(re.FindAllStringSubmatch(cfg.MigrationsTable, -1)); n > 2 {\n    return fmt.Errorf(\"MigrationsTable %q may contain at most schema+table quoted parts\", cfg.MigrationsTable)\n}","typeGuard":"func isWellFormedMigrationsTable(name string) bool {\n    return len(regexp.MustCompile(`\"(.*?)\"`).FindAllStringSubmatch(name, -1)) <= 2\n}","tryCatchPattern":"drv, err := pgxv5.WithInstance(conn, cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"too many dot characters\") {\n        return fmt.Errorf(`use \"schema\".\"table\" (max two quoted parts), got %s: %w`, cfg.MigrationsTable, err)\n    }\n    return err\n}","preventionTips":["Format quoted migrations tables as \"schema\".\"table\" only — never include the database part","Strip stray double quotes when generating table names programmatically","Unit-test table-name parsing with the same regex the driver uses"],"tags":["postgresql","migrations","config","naming"],"backgroundTag":"migrations-table-name-invalid","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}