PHPackages                             effiana/migration-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. effiana/migration-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

effiana/migration-bundle
========================

Schema and data migration for BAP

2.0.1(5y ago)03243MITPHPPHP ^7.2 | ^7.4 | ^8.0CI failing

Since Jan 28Pushed 5y agoCompare

[ Source](https://github.com/Effiana/MigrationBundle)[ Packagist](https://packagist.org/packages/effiana/migration-bundle)[ RSS](/packages/effiana-migration-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (9)Dependencies (16)Versions (11)Used By (3)

EffianaMigrationBundle
======================

[](#effianamigrationbundle)

EffianaMigrationBundle extends DBAL (database abstraction layer) and provides the ability for developers to manage and deploy changes in the application database schema programmatically in a consistent, structured way using Migrations and Fixtures classes.

Database structure migrations
-----------------------------

[](#database-structure-migrations)

Each bundle can have migration files that allow to update database schema.

Migration files should be located in `Migrations\Schema\version_number` folder. A version number must be an PHP-standardized version number string, but with some limitations. This string must not contain "." and "+" characters as a version parts separator. More info about PHP-standardized version number string can be found in [PHP manual](http://php.net/manual/en/function.version-compare.php).

Each migration class must implement [Migration](src/Migration/Migration.php) interface and must implement `up` method. This method receives a current database structure in `schema` parameter and `queries` parameter which can be used to add additional queries.

With `schema` parameter, you can create or update database structure without fear of compatibility between database engines. If you want to execute additional SQL queries before or after applying a schema modification, you can use `queries` parameter. This parameter represents a [query bag](src/Migration/QueryBag.php) and allows to add additional queries which will be executed before (`addPreQuery` method) or after (`addQuery` or `addPostQuery` method). A query can be a string or an instance of a class implements [MigrationQuery](src/Migration/MigrationQuery.php) interface. There are several ready to use implementations of this interface:

- [SqlMigrationQuery](src/Migration/SqlMigrationQuery.php) - represents one or more SQL queries
- [ParametrizedSqlMigrationQuery](src/Migration/ParametrizedSqlMigrationQuery.php) - similar to the previous class, but each query can have own parameters.

If you need to create own implementation of [MigrationQuery](src/Migration/MigrationQuery.php) the [ConnectionAwareInterface](src/Migration/ConnectionAwareInterface.php) can be helpful. Just implement this interface in your migration query class if you need a database connection. Also you can use [ParametrizedMigrationQuery](src/Migration/ParametrizedMigrationQuery.php) class as a base class for your migration query.

If you have several migration classes within the same version and you need to make sure that they will be executed in a specified order you can use [OrderedMigrationInterface](src/Migration/OrderedMigrationInterface.php) interface.

Example of migration file:

```
