> For the complete documentation index, see [llms.txt](https://quantumphp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quantumphp.gitbook.io/docs/packages/migration/overview.md).

# Overview

The Migration package gives Quantum a small, file-based schema migration workflow for relational databases. It generates migration class stubs, applies pending migrations from your project `migrations` directory, and records applied entries in a `migrations` table.

## When to use it

Use this package when you want schema changes to travel with your application code instead of being run manually.

A typical flow looks like this:

1. create a migration file in `base_dir()/migrations`
2. implement `up()` and `down()` on a class that extends `Quantum\Migration\Migration`
3. run upgrades to apply new files
4. run downgrades to revert the latest applied files when needed

## What the package manages

`Quantum\Migration\MigrationManager` is the package entry point. It handles three jobs:

* generate scaffold files for supported actions
* discover migration files under `base_dir()/migrations`
* apply or revert them with `Quantum\Database\Factories\TableFactory`

Applied migrations are tracked in a relational table named `migrations`.

## Supported actions

Generated scaffolds support these action names:

* `create`
* `alter`
* `rename`
* `drop`

Those action names are validated strictly. Anything else throws a `MigrationException`.

## Supported database drivers

The migration runner only accepts these drivers from the active database config:

* `mysql`
* `pgsql`
* `sqlite`

This package does not run against `sleekdb` or other non-relational adapters.

## Important constraints

* The `migrations` directory must already exist before you construct `MigrationManager`.
* Upgrade mode creates the tracking table automatically if it is missing.
* Downgrade mode does not create the tracking table; if it is missing, the call fails.
* The package expects every migration file basename to match a loadable class that extends `Migration`.
* Migration execution is not wrapped in a package-level transaction, so partial failures can leave schema changes applied before tracking rows are written or removed.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quantumphp.gitbook.io/docs/packages/migration/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
