> For the complete documentation index, see [llms.txt](https://documentation.immuta.com/knowledge-base/LmMmmLqSszWn8sdGe7gH/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.immuta.com/knowledge-base/LmMmmLqSszWn8sdGe7gH/troubleshooting/stuck-prisma-migrations.md).

# Stuck Prisma Migrations During Upgrade

Occasionally when upgrading using IHC or IEHC the web pods or audit pods will fail to start due to stuck and/or incomplete prisma migrations. This process will resolve them and bring the pods up.

{% code fullWidth="true" %}

```
178 migrations found in prisma/migrations

Error: P3009

migrate found failed migrations in the target database, new migrations will not be applied. 
Read more about how to resolve migration issues in a production database: 
https://pris.ly/d/migrate-resolve
The `20240906132648_remove_unused_sdd_conditional_tags` migration started at 2024-09-19 16:10:55.254249 UTC failed
```

{% endcode %}

1. Review the error within the offending pod and identify which migration it is stating is failing to complete. The format of the error will tell you (Refer to example error above)
   1. In the example above the offending migration is "20240906132648\_remove\_unused\_sdd\_conditional\_tags" yours will likely be different so note this down
2. Download the script attached to this article and make the edits needed based upon the error message presented
3. You can run the script with the following command
   1. kubectl -n \<NAMESPACE> apply -f \<LOCATION OF DOWNLOADED SCRIPT>
4. This will generate a new pod that will connect to the database and manually force run the migration that is failing to complete on its own.
5. Once it is complete (should be instant) re-run the helm upgrade command to see if the web pods come back up.
   1. In the event that the web pods fail once again with a migration, it might be that there were multiple migrations that have failed. In this scenario alter the script again with the new migration that was listed as failed and re-run the script (might need to delete the job)

{% file src="/files/ArYSPaXS9YTOCVIs6X2e" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.immuta.com/knowledge-base/LmMmmLqSszWn8sdGe7gH/troubleshooting/stuck-prisma-migrations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
