phacility/phabricator · error · AphrontSchemaQueryException
1146, 1049, 1054
1146, 1049, 1054
Error message
#%d: %s
What it means
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.
Source
Thrown at src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:366
case 1142: // Access denied to table
case 1143: // Access denied to column
case 1227: // Access denied (e.g., no SUPER for SHOW SLAVE STATUS).
// See T13622. Try to help users figure out that this is a GRANT
// problem.
$more = pht(
'This error usually indicates that you need to "GRANT" the '.
'MySQL user additional permissions. See "GRANT" in the MySQL '.
'manual for help.');
throw new AphrontAccessDeniedQueryException("{$message}\n\n{$more}");
case 1045: // Access denied (auth)
throw new AphrontInvalidCredentialsQueryException($message);
case 1146: // No such table
case 1049: // No such database
case 1054: // Unknown column "..." in field list
throw new AphrontSchemaQueryException($message);
}
// TODO: 1064 is syntax error, and quite terrible in production.
return null;
}
protected function throwConnectionException($errno, $error, $user, $host) {
$this->throwCommonException($errno, $error);
$message = pht(
'Attempt to connect to %s@%s failed with error #%d: %s.',
$user,
$host,
$errno,
$error);
throw new AphrontConnectionQueryException($message, $errno);View on GitHub (pinned to 5720a38cfe)
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
Example fix
# before: new code deployed, old schema svn up phabricator/ && restart_phabricator # => AphrontSchemaQueryException: #1054 Unknown column ... # after: upgrade storage as part of every deploy svn up phabricator/ phabricator/bin/storage upgrade --force # or without --force after review restart_phabricator
Defensive patterns
Strategy: validation
Validate before calling
// Deploy gate: refuse to serve traffic on a stale schema. // phabricator/bin/storage status -> must show no unapplied patches // phabricator/bin/storage upgrade -> apply, before switching traffic // Then verify namespace/database resolution: // phabricator/bin/config get storage.default-namespace
Try / catch
try {
$rows = queryfx_all($conn_r, '...');
} catch (AphrontSchemaQueryException $ex) {
// Code newer than schema: trigger an out-of-band 'storage upgrade needed'
// alert instead of letting raw 1146/1054 errors reach users.
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 1062
- Parameter "paths" to Conduit API method "differential.query"
- Unable to load MySQL blob file '%s'!
- Keyring configuration has an invalid key specification (at i
- Unexpected hint format at index "%s": %s
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/bd6e14bb808fbb2d.
Report an issue: GitHub.