{"record":{"id":"ec16f6916557d339","repo":"golang-migrate/migrate","slug":"x-migrations-table-must-be-quoted-for-instance-ec16f6","errorCode":null,"errorMessage":"x-migrations-table must be quoted (for instance '\"migrate\".\"schema_migrations\"') when x-migrations-table-quoted is enabled, current value is: %s","messagePattern":"x-migrations-table must be quoted \\(for instance '\"migrate\"\\.\"schema_migrations\"'\\) when x-migrations-table-quoted is enabled, current value is: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/postgres/postgres.go","lineNumber":172,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdb, err := sql.Open(\"postgres\", migrate.FilterCustomQuery(purl).String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmigrationsTable := purl.Query().Get(\"x-migrations-table\")\n\tmigrationsTableQuoted := false\n\tif s := purl.Query().Get(\"x-migrations-table-quoted\"); len(s) > 0 {\n\t\tmigrationsTableQuoted, err = strconv.ParseBool(s)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse option x-migrations-table-quoted: %w\", err)\n\t\t}\n\t}\n\tif (len(migrationsTable) > 0) && (migrationsTableQuoted) && ((migrationsTable[0] != '\"') || (migrationsTable[len(migrationsTable)-1] != '\"')) {\n\t\treturn nil, fmt.Errorf(\"x-migrations-table must be quoted (for instance '\\\"migrate\\\".\\\"schema_migrations\\\"') when x-migrations-table-quoted is enabled, current value is: %s\", migrationsTable)\n\t}\n\n\tstatementTimeoutString := purl.Query().Get(\"x-statement-timeout\")\n\tstatementTimeout := 0\n\tif statementTimeoutString != \"\" {\n\t\tstatementTimeout, err = strconv.Atoi(statementTimeoutString)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tmultiStatementMaxSize := DefaultMultiStatementMaxSize\n\tif s := purl.Query().Get(\"x-multi-statement-max-size\"); len(s) > 0 {\n\t\tmultiStatementMaxSize, err = strconv.Atoi(s)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif multiStatementMaxSize <= 0 {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/postgres/postgres.go#L154-L190","documentation":"This error comes from the postgres driver's Open() when both x-migrations-table and x-migrations-table-quoted=true are set in the connection URL. The quoted flag tells the driver to treat the migrations table name as fully quoted SQL (e.g. \"migrate\".\"schema_migrations\"), so the value must already start and end with a double quote. If it does not, the driver refuses to build a safely quoted identifier and fails fast.","triggerScenarios":"Calling Open or New with a postgres URL like postgres://user:pass@host/db?x-migrations-table=migrate.schema_migrations&x-migrations-table-quoted=true where the table value lacks leading/trailing double quotes.","commonSituations":"Developers enable x-migrations-table-quoted to support mixed-case or reserved-word table names but forget that the flag requires the value itself to be pre-quoted with escaped double quotes in the URL; this is common after copying a plain x-migrations-table value from an unquoted config.","solutions":["Wrap the value in double quotes in the URL, percent-encoding them if your client requires: x-migrations-table=%22migrate%22.%22schema_migrations%22","Set x-migrations-table-quoted=false (or remove it) if quoting is not actually needed","Rename the migrations table to a lowercase, non-reserved name and drop the quoted flag"],"exampleFix":"// before\ndsn := \"postgres://u:p@host/db?x-migrations-table=migrate.schema_migrations&x-migrations-table-quoted=true\"\n// after\ndsn := \"postgres://u:p@host/db?x-migrations-table=%22migrate%22.%22schema_migrations%22&x-migrations-table-quoted=true\"","handlingStrategy":"validation","validationCode":"func validateMigrationsTable(dsn *url.URL) error {\n    table := dsn.Query().Get(\"x-migrations-table\")\n    quoted, _ := strconv.ParseBool(dsn.Query().Get(\"x-migrations-table-quoted\"))\n    if quoted && table != \"\" && !(strings.HasPrefix(table, \"\\\"\") && strings.HasSuffix(table, \"\\\"\")) {\n        return fmt.Errorf(\"x-migrations-table must be wrapped in double quotes: %q\", table)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the quoted table value programmatically with %q so quotes are always present","Percent-encode quotes when hand-writing URLs (%22...%22)","Only set x-migrations-table-quoted when the table name is mixed-case or a reserved word"],"tags":["postgres","configuration","migrations","validation"],"backgroundTag":"sql-identifier-quoting","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}