Dirthara Migration
Dirthara Migration creates, runs, previews, and rolls back database migrations, and rebuilds databases from them for the Dirthara framework. It builds on
dirthara/database for connections and locks and on
dirthara/schema for schema changes, and decides which migrations run, in what
order, on which connection, and records what has been applied.
Concepts
| Concept | Meaning |
|---|---|
| Migration | A PHP file that returns an object implementing Dirthara\Migration\Contract\Migration, with up() and down(). |
| Name | The migration's identity: an ASCII identifier, compared case-insensitively. |
| Index | The migration's ordering value, usually a UTC timestamp such as 2026_09_30_101500. |
| Connection | The database connection a migration runs on. null means the default connection. |
| History | The table that records every applied migration, where it ran, and in which batch. |
| Batch | The migrations one migrate() call applied. A batch rollback reverses one batch. |
| Lock | A named database lock that keeps two runs, rollbacks, refreshes, or fresh runs from working at the same time. |
Migrations can live in any number of directories, for example one per domain or module. A run loads all of them, checks them as one set, and orders them per connection.
Pages
- Installation: requirements and installing the package.
- Setting up: building the services the migrator needs.
- Writing migrations: the migration contract, names, indexes, connections, and hooks.
- Creating migrations: generating migration files from templates.
- Running migrations: what
migrate()checks, in which order it runs, and how it fails. - Rolling back migrations: batch and step rollback.
- Previewing migrations: the plan of a run or rollback, without running anything.
- Refreshing migrations: rolling back every migration and running them all again.
- Fresh migrations: dropping every table on the migration connections and running every migration again.
- Migration locking: how runs are protected against each other.
- Loading migrations: how migration files are found and loaded from any filesystem.
- Migration history: the history table and the repository around it.
- Exceptions: every exception the package throws and when.