hackzilla / doctrine-migration-pruner-bundle
Prune excess doctrine migrations
Package info
github.com/hackzilla/DoctrineMigrationPrunerBundle
Type:symfony-bundle
pkg:composer/hackzilla/doctrine-migration-pruner-bundle
Requires
- php: ^8.2
- doctrine/dbal: ^3.6 || ^4.0
- doctrine/doctrine-migrations-bundle: ^3.7 || ^4.0
- symfony/yaml: ^7.0 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^10.5 || ^11.0 || ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Features
- Automatically prunes old migration files and their corresponding database entries just before running new Doctrine migrations.
- Designed to work in production; migration files should be absent, leaving only the database entries to be removed.
- Handles Doctrine migrations' multiple configurations.
- Prevents warnings about missing migration files if you manually removed them.
Supported Platforms
- MySQL
- Sqlite
Prerequisites
- Requires Doctrine Migrations Bundle
^3.0. - Check the compatibility matrix below before choosing a bundle release.
Compatibility
Use this matrix when selecting a bundle release for an application. A supported combination is one the release was built to load with; it is not a substitute for testing the application's own migrations and database platform.
| Bundle version | Symfony 6 | Symfony 7 | Symfony 8 |
|---|---|---|---|
0.1.0–0.3.0 |
Supported (PHP 8.1+) | Not supported | Not supported |
0.4.0 |
Supported (PHP 8.1+) | Supported (PHP 8.2+) | Not yet supported |
| Current development release | Not targeted | DBAL 3 or 4 | DBAL 4 |
The historical releases listed above require Doctrine Migrations Bundle ^3.0.
Version 0.4.0 adds the return types required by Symfony 7. It does not make a
Symfony 8 compatibility claim.
The current development release requires PHP 8.2 or later and supports Doctrine
DBAL ^3.6 or ^4.0. Symfony 7 works with Doctrine Migrations Bundle ^3.7
(and can use ^4.0 with DBAL 4 on PHP 8.4 or later). Symfony 8 uses Doctrine
Migrations Bundle ^4.0, which requires DBAL 4 and PHP 8.4 or later.
Installation
To install the Doctrine Migration Pruner Bundle, you can use composer:
composer require hackzilla/doctrine-migration-pruner-bundle
Configuration
Add the following to your application's config:
hackzilla_doctrine_migration_pruner: remove_migrations_before: '2007-05-01' # Can be null or a valid date-time
It's advisable to start with an earlier date-time.
Usage
Run your Doctrine migrations as you normally would:
bin/console doctrine:migrations:migrate
Note: The pruning operation will not execute if the --dry-run option has been specified.
Testing
There are currently no tests available.
However, you can use Doctrine Migration Pruner Repo to test the migration pruning.
Contributions and Issues
See all contributors on GitHub.
Please report issues using GitHub's issue tracker: GitHub Repo
If you find this project useful, consider buying me a coffee.
License
This bundle is released under the MIT license. See the LICENSE file for details.