BerriAI/litellm · error · RuntimeError

Database migration failed due to insufficient permissions. P

Error message

Database migration failed due to insufficient permissions. Please grant the required privileges and retry.

Prisma error:
{stderr}

What it means

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.

Source

Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:630

                                # `except CalledProcessError` handler —
                                # re-raising CalledProcessError from here
                                # would escape as itself, bypassing
                                # proxy_cli.py's `except RuntimeError`.
                                raise RuntimeError(
                                    f"Failed to mark migration {name} as applied "
                                    f"after idempotent recovery. Manual "
                                    f"intervention may be required.\n\n"
                                    f"Detail: {resolve_err}"
                                ) from resolve_err
                            continue
                        raise RuntimeError(
                            "Database migration failed and cannot be auto-recovered. "
                            f"Manual intervention required.\n\nPrisma error:\n{stderr}"
                        ) from e

                    if "P3018" in stderr:
                        if ProxyExtrasDBManager._is_permission_error(stderr):
                            raise RuntimeError(
                                "Database migration failed due to insufficient "
                                "permissions. Please grant the required privileges "
                                f"and retry.\n\nPrisma error:\n{stderr}"
                            ) from e

                        migration_match = re.search(
                            r"Migration name: (\d+_\S+)", stderr
                        )
                        if (
                            migration_match
                            and ProxyExtrasDBManager._is_idempotent_error(stderr)
                        ):
                            name = migration_match.group(1)
                            logger.info(
                                f"Migration {name} SQL hit idempotent error — marking applied and retrying"
                            )
                            try:
                                ProxyExtrasDBManager._roll_back_migration(name)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Grant the database user the privileges Prisma needs (CREATE/ALTER/DROP, schema write) and retry the migration.
  2. Run migrations as a user with DDL rights.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:630 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/e3d66768f32f3cd4. Report an issue: GitHub.