Doctrine Migrations

PHP library for versioning and applying incremental database schema changes as migration classes

Tool
Composer
v3.9.7
4,767stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
64/100Good
Development Activity40
Maintenance52
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture87
Code Quality88
Innovation76
Learning Curve74

Doctrine Migrations is a PHP library, built on Doctrine DBAL, for managing database schema changes over time. It represents each change as a versioned migration class with up and down methods, and provides a command-line tool to generate, execute, and roll back those migrations in a controlled, repeatable way.

It tracks which migrations have run using a metadata table, supports generating diffs against your current schema, and integrates with Symfony and other frameworks through the Doctrine ecosystem, making database schema evolution safe to version-control and deploy.

What You Get

  • A command-line tool to generate, run, roll back, and inspect migrations
  • AbstractMigration base class with up() and down() lifecycle methods
  • Automatic diff generation against your current Doctrine schema
  • A metadata storage table that tracks executed migration versions
  • Configurable finders, repositories, and a dependency-injection factory for framework integration

Common Use Cases

  • Versioning database schema changes alongside application code
  • Generating migration diffs from Doctrine ORM entity mappings
  • Applying and rolling back schema changes across dev, staging, and production
  • Coordinating database updates in CI/CD deployment pipelines

Under The Hood

Architecture - The library centers on a Migrator (Migrator.php / DbalMigrator.php) that executes ordered Version objects, each wrapping an AbstractMigration subclass; a MigrationsRepository (FilesystemMigrationsRepository) discovers migration files via a Finder, Metadata storage tracks executed versions, and a Generator plus SchemaDumper produce new migration classes from schema diffs, all wired together by a DependencyFactory.

Tech Stack - Written in modern PHP on top of Doctrine DBAL, distributed through Composer, with a bin/doctrine-migrations console entry point built on Symfony Console; quality tooling includes PHPStan, PHP_CodeSniffer, and a phpunit suite, and a box.json-driven PHAR build.

Code Quality - The codebase is well-structured into focused namespaces (Configuration, Metadata, Provider, Query, Generator, Version), carries a comprehensive tests/ suite, static analysis config (phpstan.neon.dist), coding-standard rules (phpcs.xml.dist), and documented upgrade paths (UPGRADE.md), reflecting a mature, professionally maintained project.

API Design - Users subclass AbstractMigration and implement up()/down() with a fluent schema API, then drive everything through clearly named CLI commands (migrations:generate, migrate, diff, rollup). The DependencyFactory makes deep customization possible, though the flexibility adds some configuration surface for advanced setups.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search