{"record":{"id":"29d4f79aba4af5c1","repo":"passbolt/passbolt_api","slug":"the-database-schema-does-not-match-the-one-expected","errorCode":null,"errorMessage":"The database schema does not match the one expected","messagePattern":"The database schema does not match the one expected","errorType":"exception","errorClass":"CakeException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltCe/WebInstaller/src/Utility/DatabaseConfiguration.php","lineNumber":121,"sourceCode":"        /** @var \\Cake\\Database\\Connection $connection */\n        $connection = ConnectionManager::get('default');\n\n        return $connection->getSchemaCollection()->listTables();\n    }\n\n    /**\n     * Validate the database schema.\n     *\n     * @throws \\Cake\\Core\\Exception\\CakeException If the database schema does not validate\n     * @return void\n     */\n    public static function validateSchema(): void\n    {\n        $tables = self::getTables();\n        $expectedTables = self::getSchemaTables(1);\n        foreach ($expectedTables as $expectedTable) {\n            if (!in_array($expectedTable, $tables)) {\n                throw new CakeException(__('The database schema does not match the one expected'));\n            }\n        }\n    }\n\n    /**\n     * Get schema tables list. (per version number).\n     *\n     * @param int $version passbolt major version number.\n     * @return array\n     */\n    public static function getSchemaTables(int $version = 2): array\n    {\n        // List of tables for passbolt v1.\n        $tables = [\n            'authentication_tokens',\n            'avatars',\n            'comments',\n            'email_queue',","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/WebInstaller/src/Utility/DatabaseConfiguration.php#L103-L139","documentation":"WebInstaller DatabaseConfiguration::validateSchema() compares the tables present in the database against the expected table list for schema version 1 and throws if any expected table is missing. It is the web installer's pre-install sanity check that the DB matches passbolt's expected schema.","triggerScenarios":"Calling validateSchema() (e.g. from the installer's hasAdmin / install check endpoints) when one or more tables returned by getSchemaTables(1) do not exist on the current default connection.","commonSituations":"Partial or failed migration run left an incomplete schema; the connection points to an empty or wrong database; the database user lacks privileges so only some tables were created; schema drift between passbolt versions.","solutions":["Check that the default datasource points at the intended database (config/app.php, app.local.php) and run bin/cake passbolt healthcheck.","Run migrations manually to see the underlying error: bin/cake passbolt migrate (or bin/cake migrations migrate) and fix the reported failure.","Verify the DB user has CREATE/ALTER privileges on the schema, then re-run migrations.","If the schema is intentionally different, restore a proper backup of the passbolt database instead of editing the expected table list."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$tables = $connection->getSchemaCollection()->listTables();\nforeach (\\Passbolt\\WebInstaller\\Utility\\DatabaseConfiguration::getSchemaTables(1) as $t) {\n    if (!in_array($t, $tables, true)) {\n        // fix DB or run migrations before the installer check\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    DatabaseConfiguration::validateSchema();\n} catch (\\Cake\\Core\\Exception\\CakeException $e) {\n    // fall back to CLI migration: bin/cake passbolt migrate\n}","preventionTips":["Run bin/cake passbolt migrate from CLI before using the web installer checks.","Point the default datasource at the correct database for the environment.","Grant the DB user full CREATE/ALTER privileges.","Keep schema in sync between environments; restore from matching-version backups."],"tags":["webinstaller","database","schema","migrations"],"backgroundTag":"schema-validation-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}