{"record":{"id":"bd6e14bb808fbb2d","repo":"phacility/phabricator","slug":"1146-1049-1054","errorCode":"1146, 1049, 1054","errorMessage":"#%d: %s","messagePattern":"#%d: %s","errorType":"exception","errorClass":"AphrontSchemaQueryException","httpStatus":null,"severity":"error","filePath":"src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php","lineNumber":366,"sourceCode":"      case 1142: // Access denied to table\n      case 1143: // Access denied to column\n      case 1227: // Access denied (e.g., no SUPER for SHOW SLAVE STATUS).\n\n        // See T13622. Try to help users figure out that this is a GRANT\n        // problem.\n\n        $more = pht(\n          'This error usually indicates that you need to \"GRANT\" the '.\n          'MySQL user additional permissions. See \"GRANT\" in the MySQL '.\n          'manual for help.');\n\n        throw new AphrontAccessDeniedQueryException(\"{$message}\\n\\n{$more}\");\n      case 1045: // Access denied (auth)\n        throw new AphrontInvalidCredentialsQueryException($message);\n      case 1146: // No such table\n      case 1049: // No such database\n      case 1054: // Unknown column \"...\" in field list\n        throw new AphrontSchemaQueryException($message);\n    }\n\n    // TODO: 1064 is syntax error, and quite terrible in production.\n\n    return null;\n  }\n\n  protected function throwConnectionException($errno, $error, $user, $host) {\n    $this->throwCommonException($errno, $error);\n\n    $message = pht(\n      'Attempt to connect to %s@%s failed with error #%d: %s.',\n      $user,\n      $host,\n      $errno,\n      $error);\n\n    throw new AphrontConnectionQueryException($message, $errno);","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php#L348-L384","documentation":"MySQL reported a missing schema object while running a query: 1146 (table doesn't exist), 1049 (database doesn't exist), or 1054 (unknown column). These are mapped to AphrontSchemaQueryException because in Phabricator they almost always mean the running code expects a newer schema than the database has. The database name itself may also be wrong (namespace mismatch), producing 1049.","triggerScenarios":"Running new code that queries a table/column introduced by an unapplied storage patch; storage.default-namespace resolving to a different database name than the one that was initialized; a partially applied or interrupted bin/storage upgrade; an extension or fork referencing a column that never existed in this tree.","commonSituations":"Deploying a new Phabricator version without running bin/storage upgrade first; pointing a test install at a namespace initialized long ago; restoring a dump into a differently-named database; third-party patches assuming schema changes that were reverted.","solutions":["Apply pending schema patches: phabricator/bin/storage upgrade (check bin/storage status first)","Verify the namespace and database configuration: storage.default-namespace, mysql.host, and cluster.databases must all resolve to the database you actually initialized","Inspect what exists: phabricator/bin/storage databases / status to see whether the expected tables and columns are present","If a custom patch references the column, either land its storage patch or remove the reference"],"exampleFix":"# before: new code deployed, old schema\nsvn up phabricator/ && restart_phabricator\n# => AphrontSchemaQueryException: #1054 Unknown column ...\n\n# after: upgrade storage as part of every deploy\nsvn up phabricator/\nphabricator/bin/storage upgrade --force  # or without --force after review\nrestart_phabricator","handlingStrategy":"validation","validationCode":"// Deploy gate: refuse to serve traffic on a stale schema.\n// phabricator/bin/storage status   -> must show no unapplied patches\n// phabricator/bin/storage upgrade  -> apply, before switching traffic\n// Then verify namespace/database resolution:\n// phabricator/bin/config get storage.default-namespace","typeGuard":null,"tryCatchPattern":"try {\n  $rows = queryfx_all($conn_r, '...');\n} catch (AphrontSchemaQueryException $ex) {\n  // Code newer than schema: trigger an out-of-band 'storage upgrade needed'\n  // alert instead of letting raw 1146/1054 errors reach users.\n}","preventionTips":["Make 'bin/storage upgrade' a mandatory step of every deploy, ordered before the code switch","Check bin/storage status in CI or deploy scripts and abort when patches are unapplied","Keep storage.default-namespace identical across config environments that share a database","Treat a third-party patch referencing a column as requiring its storage patch in the same change"],"tags":["mysql","schema","migration","storage-upgrade","lisk"],"backgroundTag":"database-schema-mismatch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}