# DATABASE_MIGRATION_PARTLY_APPLIED

<!-- Generated by docs/modules/diagnostics from the package catalogs. Write a guide in docs/diagnostics/<CODE>.md instead of editing this file. -->

A Postgres migration with `-- vitehub:no-transaction` runs one statement at a time. If a statement fails, the earlier statements stay applied. If the ledger write fails, all statements stay applied. In both cases the next run starts from the first statement of the file.

If the error names an invalid index, drop that index with `DROP INDEX CONCURRENTLY IF EXISTS` in `vitehub database sql`. The list has only the indexes that this file left. An invalid index does not become valid when `CREATE INDEX CONCURRENTLY IF NOT EXISTS` skips it, so the file stays pending until you drop it.

If a statement between `BEGIN` and `COMMIT` fails, or the file ends without `COMMIT`, ViteHub rolls back that transaction and does not record the file.

Fix the reported problem and make each statement safe to run again. Then use `vitehub database migrate` or start the server again.

## Source

`DATABASE_MIGRATION_PARTLY_APPLIED` belongs to the `database` package. Its catalog entry is in [`src/error-diagnostics.ts`](https://github.com/vite-hub/vitehub/blob/main/packages/database/src/error-diagnostics.ts#L274). It is raised in [`src/runtime/migrate-on-start.ts`](https://github.com/vite-hub/vitehub/blob/main/packages/database/src/runtime/migrate-on-start.ts#L939).

See [all Database diagnostics](https://vitehub.dev/docs/database/diagnostics).

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/database.md)
- [Get started](https://vitehub.dev/raw/docs/database/get-started.md)
- [Configure](https://vitehub.dev/raw/docs/database/configure.md)
- [Server API](https://vitehub.dev/raw/docs/database/server-api.md)
- [Agent capability](https://vitehub.dev/raw/docs/database/agent-capability.md)
- [Hosts](https://vitehub.dev/raw/docs/database/hosts.md)
- [Limits and errors](https://vitehub.dev/raw/docs/database/limits-and-errors.md)

Next: [DATABASE_MIGRATION_SCHEMA_CONFLICT](https://vitehub.dev/raw/docs/database/diagnostics/database_migration_schema_conflict.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
