{"record":{"id":"e3d66768f32f3cd4","repo":"BerriAI/litellm","slug":"database-migration-failed-due-to-insufficient-perm","errorCode":null,"errorMessage":"Database migration failed due to insufficient permissions. Please grant the required privileges and retry.\n\nPrisma error:\n{stderr}","messagePattern":"Database migration failed due to insufficient permissions\\. Please grant the required privileges and retry\\.\n\nPrisma error:\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm-proxy-extras/litellm_proxy_extras/utils.py","lineNumber":630,"sourceCode":"                                # `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)\n                        ):\n                            name = migration_match.group(1)\n                            logger.info(\n                                f\"Migration {name} SQL hit idempotent error — marking applied and retrying\"\n                            )\n                            try:\n                                ProxyExtrasDBManager._roll_back_migration(name)","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm-proxy-extras/litellm_proxy_extras/utils.py#L612-L648","documentation":"RuntimeError indicating the migration failed specifically due to insufficient database privileges (prisma stderr reported a permissions error). Granting the DB user the required privileges and retrying is the remediation.","triggerScenarios":"Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:630 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Grant the database user the privileges Prisma needs (CREATE/ALTER/DROP, schema write) and retry the migration.","Run migrations as a user with DDL rights."],"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-14T00:17:10.932Z"}