{"record":{"id":"5aa7579673064b67","repo":"BerriAI/litellm","slug":"database-migration-failed-and-cannot-be-auto-recov","errorCode":null,"errorMessage":"Database migration failed and cannot be auto-recovered. Manual intervention required.\n\nPrisma error:\n{stderr}","messagePattern":"Database migration failed and cannot be auto-recovered\\. Manual intervention required\\.\n\nPrisma error:\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm-proxy-extras/litellm_proxy_extras/utils.py","lineNumber":623,"sourceCode":"                            try:\n                                ProxyExtrasDBManager._resolve_specific_migration(name)\n                            except (\n                                subprocess.CalledProcessError,\n                                subprocess.TimeoutExpired,\n                            ) as resolve_err:\n                                # We're already inside the outer\n                                # `except CalledProcessError` handler —\n                                # re-raising CalledProcessError from here\n                                # would escape as itself, bypassing\n                                # proxy_cli.py's `except RuntimeError`.\n                                raise RuntimeError(\n                                    f\"Failed to mark migration {name} as applied \"\n                                    f\"after idempotent recovery. Manual \"\n                                    f\"intervention may be required.\\n\\n\"\n                                    f\"Detail: {resolve_err}\"\n                                ) from resolve_err\n                            continue\n                        raise RuntimeError(\n                            \"Database migration failed and cannot be auto-recovered. \"\n                            f\"Manual intervention required.\\n\\nPrisma error:\\n{stderr}\"\n                        ) from e\n\n                    if \"P3018\" in stderr:\n                        if ProxyExtrasDBManager._is_permission_error(stderr):\n                            raise RuntimeError(\n                                \"Database migration failed due to insufficient \"\n                                \"permissions. Please grant the required privileges \"\n                                f\"and retry.\\n\\nPrisma error:\\n{stderr}\"\n                            ) from e\n\n                        migration_match = re.search(\n                            r\"Migration name: (\\d+_\\S+)\", stderr\n                        )\n                        if (\n                            migration_match\n                            and ProxyExtrasDBManager._is_idempotent_error(stderr)","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm-proxy-extras/litellm_proxy_extras/utils.py#L605-L641","documentation":"Terminal RuntimeError from the migration runner: a prisma migrate command failed and none of the automatic recovery paths (rollback, idempotent re-resolve) applied. The raw prisma stderr is embedded; the DB needs manual intervention.","triggerScenarios":"Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:623 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the Prisma error in {stderr}; resolve the migration conflict manually (e.g. prisma migrate resolve) and retry.","Restore from backup if the schema is in an inconsistent state."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}