PHPackages                             php-database-migration/php-database-migration - 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. php-database-migration/php-database-migration

ActiveLibrary[Database &amp; ORM](/categories/database)

php-database-migration/php-database-migration
=============================================

rake and mybatis SQL migration tool

v3.8.0(7y ago)8961.2k—5.6%33[4 PRs](https://github.com/alwex/php-database-migration/pulls)MITPHPPHP &gt;=5.3.0CI failing

Since Jun 21Pushed 4y ago6 watchersCompare

[ Source](https://github.com/alwex/php-database-migration)[ Packagist](https://packagist.org/packages/php-database-migration/php-database-migration)[ Docs](https://github.com/alwex/php-database-migration)[ RSS](/packages/php-database-migration-php-database-migration/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (42)Used By (0)

PhpDbMigration - full PHP database migration tool
=================================================

[](#phpdbmigration---full-php-database-migration-tool)

[![Build Status](https://camo.githubusercontent.com/27579237d0038f38bce6c94adc1278a9ad40df13a2542af09383f450ae4c5a86/68747470733a2f2f7472617669732d63692e6f72672f616c7765782f7068702d64617461626173652d6d6967726174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alwex/php-database-migration)![Packagist](https://camo.githubusercontent.com/2cb23bbe91f60e031657993e935ba3804583b89de88894e77542f55b1d3797ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d64617461626173652d6d6967726174696f6e2f7068702d64617461626173652d6d6967726174696f6e2e7376673f6d61784167653d32353932303030)[![Version](https://camo.githubusercontent.com/054cd95f47d7ff27bc56e28b8de6680a76753a32a04776f0e315deda41ab0087/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d64617461626173652d6d6967726174696f6e2f7068702d64617461626173652d6d6967726174696f6e2e7376673f7374796c653d666c6174)](https://packagist.org/packages/php-database-migration/php-database-migration)

[![SensioLabsInsight](https://camo.githubusercontent.com/5d8c61f864186d36fc684a1b5b2e544fa41b768fe621915fd79cc35605de00a5/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35333633653965302d313233612d346138652d616436342d6362303139653633626262612f6269672e706e67)](https://insight.sensiolabs.com/projects/5363e9e0-123a-4a8e-ad64-cb019e63bbba)

This is a full standalone PHP tool based on [Symfony Console](http://symfony.com/doc/current/components/console)and inspired by the Rails database migration tool and MyBatis. It merges the functionality of the two tools and has been designed to be as flexible as possible.

Usage
-----

[](#usage)

```
$ ./bin/migrate
Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help            Displays help for a command
  list            Lists commands
 migrate
  migrate:addenv  Initialise an environment to work with php db migrate
  migrate:create  Create a SQL migration
  migrate:down    Rollback all waiting migration down to [to] option if precised
  migrate:init    Create the changelog table on your environment database
  migrate:status  Display the current status of the specified environment
  migrate:up      Execute all waiting migration up to [to] option if precised

```

Installing it to your project
-----------------------------

[](#installing-it-to-your-project)

Just add it to your composer.json (don't forget to specify your bin directory) Warning, all migrate commands must be executed on your root folder like `bin/migrate migrate:command...`

```
{
    "name": "jdoe/testproject",
    "authors": [
        {
            "name": "Jhon DOE",
            "email": "jdoe@gmail.com"
        }
    ],
    "require": {
        "php-database-migration/php-database-migration" :"3.6.*"
    },
    "config": {
        "bin-dir": "bin"
    }
}

```

Adding an environment
---------------------

[](#adding-an-environment)

The first thing to do before playing with SQL migrations is to add an environment, let's add the dev one.

```
$ ./bin/migrate migrate:addenv

```

You will be prompted to answer a series of questions about your environment, and then a config file will be saved in `./.php-database-migration/environments/[env].yml`.

Initialization
--------------

[](#initialization)

Once the environment is added, you have to initialize it. This verifies that the database connection works, and creates a new database table for tracking the current database changes:

```
$ ./bin/migrate migrate:init [env]

```

Create a migration
------------------

[](#create-a-migration)

It is time to create our first migration file.

```
$ ./bin/migrate migrate:create

```

Migrations file are like this

```
-- // add table users
-- Migration SQL that makes the change goes here.
create table users (id integer, name text);
-- @UNDO
-- SQL to undo the change goes here.
drop table users;

```

List migrations
---------------

[](#list-migrations)

View all available migrations and their status.

```
$ ./bin/migrate migrate:status [env]
+----------------+---------+------------------+--------------------+
| id             | version | applied at       | description        |
+----------------+---------+------------------+--------------------+
| 14679010838251 |         |                  | create table users |
+----------------+---------+------------------+--------------------+

```

Up and down
-----------

[](#up-and-down)

You can now up all the pending migrations. If you decide to down a migration, the last one will be downed alone to prevent mistakes. You will be asked to confirm the downgrade of your database before running the real SQL script.

```
$ ./bin/migrate migrate:up [env]

```

You can mark migrations as applied without executing SQL (e.g. if you switched from another migration system)

```
$ ./bin/migrate migrate:up [env] --changelog-only

```

For development purposes, it is also possible to up a single migration without taking care of the other ones:

```
$ ./bin/migrate migrate:up [env] --only=[migrationid]

```

or migrate to specific migration (it will run all migrations, including the specified migration)

```
$ ./bin/migrate migrate:up [env] --to=[migrationid]

```

Same thing for down:

```
$ ./bin/migrate migrate:down [env] --only=[migrationid]

```

or

```
$ ./bin/migrate migrate:down [env] --to=[migrationid]

```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 63.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Recently: every ~189 days

Total

34

Last Release

2610d ago

Major Versions

1.0.0 → 2.0.02014-02-04

2.2.1 → v3.0.02015-02-27

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/63174?v=4)[Alexandre](/maintainers/alwex)[@alwex](https://github.com/alwex)

---

Top Contributors

[![alwex](https://avatars.githubusercontent.com/u/63174?v=4)](https://github.com/alwex "alwex (31 commits)")[![br39](https://avatars.githubusercontent.com/u/25536771?v=4)](https://github.com/br39 "br39 (15 commits)")[![pyldin601](https://avatars.githubusercontent.com/u/8050895?v=4)](https://github.com/pyldin601 "pyldin601 (2 commits)")[![compwright](https://avatars.githubusercontent.com/u/138688?v=4)](https://github.com/compwright "compwright (1 commits)")

---

Tags

database-migrationsphpphp-database-migrationmigrationsqlrakemybatis

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/php-database-migration-php-database-migration/health.svg)

```
[![Health](https://phpackages.com/badges/php-database-migration-php-database-migration/health.svg)](https://phpackages.com/packages/php-database-migration-php-database-migration)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)[guikingone/scheduler-bundle

A Symfony bundle that allows to schedule and create repetitive tasks

114217.4k](/packages/guikingone-scheduler-bundle)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1183.0k1](/packages/bartlett-php-compatinfo-db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
