Skip to main content
Version: v2.0 (upcoming)

Database Migrations

config/packages/migrations.php wires Doctrine Migrations and registers the full suite of migration console commands.

What it does

  • Creates a ConfigurationLoader from the migration.paths map (namespace → directory).
  • Wires DependencyFactory using the existing EntityManagerInterface (via ExistingEntityManager).
  • Registers all standard Doctrine Migrations console commands.

Configuration parameters

KeyDefaultDescription
migration.pathsDefined in services.phpMap of PHP namespace to filesystem directory for migration classes.

The migration.paths key is an associative array where each entry maps the namespace used for generated migration class names to the directory where those files are stored.

Default value (from services.php)

'migration.paths' => add([
'Application\\Migrations' => string('{app.project_root}/migrations'),
]),

Adding a second migration directory

// services.php
use function DI\add;
use function DI\string;

'migration.paths' => add([
'Application\\Migrations' => string('{app.project_root}/migrations'),
'Application\\Module\\Migrations' => string('{app.project_root}/src/Module/migrations'),
]),

Console commands registered

CommandDescription
migrations:diffGenerates a migration by comparing the current schema to the database.
migrations:currentShows the current migration version.
migrations:dump-schemaDumps the schema to a migration file.
migrations:executeExecutes a specific migration version up or down.
migrations:generateGenerates a blank migration class.
migrations:latestShows the latest available migration version.
migrations:migrateMigrates the database to a specified version (default: latest).
migrations:rollupRolls up all migrations into a single baseline migration.
migrations:statusShows the migration status of the database.
migrations:versionManually marks a version as migrated or not migrated.
migrations:up-to-dateChecks whether the database is up to date.
migrations:sync-metadata-storageSyncs the metadata storage with the database.
migrations:listLists all available migrations and their status.

Dependencies

PackageDescription
doctrine/migrationsThe Doctrine Migrations library.