{"record":{"id":"c96c77124b88b270","repo":"golang-migrate/migrate","slug":"s-migrationstable-contains-too-many-dot-charact-c96c77","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/postgres/postgres.go","lineNumber":116,"sourceCode":"\t\t}\n\n\t\tconfig.SchemaName = schemaName.String\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\tpx := &Postgres{\n\t\tconn:   conn,\n\t\tconfig: config,\n\t}\n\n\tif err := px.ensureVersionTable(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn px, nil\n}\n\nfunc WithInstance(instance *sql.DB, config *Config) (database.Driver, error) {\n\tctx := context.Background()\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/postgres/postgres.go#L98-L134","documentation":"When MigrationsTableQuoted is true, WithConnection parses the quoted MigrationsTable with the regex \"(.*?)\" and expects at most two captures: schema and table. If more than two quoted segments are present (more than one dot), it returns this error because a Postgres identifier can only be schema.table. The driver cannot unambiguously split the name.","triggerScenarios":"Calling postgres.WithConnection (directly or via WithInstance) with Config{MigrationsTableQuoted: true, MigrationsTable: \"a\".\"b\".\"c\"} — i.e. three or more quoted identifiers.","commonSituations":"Pasting a fully-qualified name with database prefix (db.schema.table) into MigrationsTable; nested quoting mistakes producing extra \"...\" pairs; misunderstanding that only two levels are valid in Postgres identifiers.","solutions":["Reduce MigrationsTable to at most two quoted parts: \"schema\".\"table\" (drop the database name — connect to the database instead)","Use just \"table\" if the schema is the default/current one","Set MigrationsTableQuoted=false and use a simple unquoted name if quoting is unnecessary"],"exampleFix":"// before\ncfg := &postgres.Config{MigrationsTable: `\"mydb\".\"myschema\".\"schema_migrations\"`, MigrationsTableQuoted: true}\n// after\ncfg := &postgres.Config{MigrationsTable: `\"myschema\".\"schema_migrations\"`, MigrationsTableQuoted: true}","handlingStrategy":"validation","validationCode":"if cfg.MigrationsTableQuoted {\n    parts := strings.Count(cfg.MigrationsTable, \".\")\n    if parts > 1 {\n        return fmt.Errorf(\"MigrationsTable %q may have at most schema.table (one dot)\", cfg.MigrationsTable)\n    }\n}","typeGuard":null,"tryCatchPattern":"d, err := postgres.WithConnection(conn, cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"too many dot characters\") {\n        log.Fatal(\"quoted MigrationsTable must be \\\"schema\\\".\\\"table\\\" — drop the database prefix\")\n    }\n    panic(err)\n}","preventionTips":["Keep quoted migrations tables to \"schema\".\"table\" — never include the database name","Connect to the target database via the DSN instead of prefixing it in the table name","Validate the table name format in config before constructing the driver"],"tags":["configuration","identifier-quoting","validation","postgres"],"backgroundTag":"invalid-identifier-quoting","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}