PHPackages                             petrknap/php-migrationtool - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. petrknap/php-migrationtool

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

petrknap/php-migrationtool
==========================

Migration tool for PHP

v1.1.2(8y ago)02.2k1[2 PRs](https://github.com/petrknap/php-migrationtool/pulls)1MITPHPPHP &gt;=5.3.3

Since Jun 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/petrknap/php-migrationtool)[ Packagist](https://packagist.org/packages/petrknap/php-migrationtool)[ Docs](https://github.com/petrknap/php-migrationtool)[ RSS](/packages/petrknap-php-migrationtool/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (2)Versions (17)Used By (1)

Migration tool for PHP
======================

[](#migration-tool-for-php)

- [What is Migration?](#what-is-migration)
- [Usage of php-migrationtool](#usage-of-php-migrationtool)
    - [Migration files](#migration-files)
    - [Migration tools](#migration-tools)
        - [SQL migration tool](#sql-migration-tool)
- [How to install](#how-to-install)

What is Migration?
------------------

[](#what-is-migration)

> **Data migration** is the process of transferring data between storage types, formats, or computer systems. It is a key consideration for any system implementation, upgrade, or consolidation. Data migration is usually **performed programmatically to achieve an automated migration**, freeing up human resources from tedious tasks. Data migration occurs for a variety of reasons, including server or storage equipment replacements, maintenance or upgrades, application migration, website consolidation and data center relocation.
>
> \-- [Data migration - Wikipedia, The Free Encyclopedia](https://en.wikipedia.org/w/index.php?title=Data_migration&oldid=716195543)

Usage of php-migrationtool
--------------------------

[](#usage-of-php-migrationtool)

### Migration files

[](#migration-files)

Migration file is file placed in special directory like `/migrations`. Migration file name contains 3 parts: *migration id*, *description* separated by space (optional) and *extension* separated by dot (optional) - the valid names for migration files are `{id}`, `{id}.{extension}`, `{id} {description}` and `{id} {description}.{extension}`.

```
user@localhost:~/project/migrations$ ls
M0001  M0002.ext  M0003 - Third migration  M0004 - Fourth migration.ext

```

Migration tools process **all files located in directory in ascending order** (sorted by file names). If applying of any migration file throws exception, the changes invoked by this file will be canceled and migration tool will be stopped.

Migration tools also contain lists of applied migrations and guarantee that every file will be processed only once and only in case that there is not applied migration with higher id.

### Migration tools

[](#migration-tools)

All migration tools implement `MigrationToolInterface` with method `migrate()`.

```
