Skip to main content

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​

ConceptMeaning
MigrationA PHP file that returns an object implementing Dirthara\Migration\Contract\Migration, with up() and down().
NameThe migration's identity: an ASCII identifier, compared case-insensitively.
IndexThe migration's ordering value, usually a UTC timestamp such as 2026_09_30_101500.
ConnectionThe database connection a migration runs on. null means the default connection.
HistoryThe table that records every applied migration, where it ran, and in which batch.
BatchThe migrations one migrate() call applied. A batch rollback reverses one batch.
LockA 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​