PHPackages                             tcdev/migrant - 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. tcdev/migrant

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

tcdev/migrant
=============

Migrant: A simple utility for database migration.

v1.0.0(2y ago)02MITPHPPHP &gt;=5.4.0

Since Oct 25Pushed 2y agoCompare

[ Source](https://github.com/thrivecart/migrant)[ Packagist](https://packagist.org/packages/tcdev/migrant)[ RSS](/packages/tcdev-migrant/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Migrant -- Database migration tool
==================================

[](#migrant----database-migration-tool)

[![Build Status](https://camo.githubusercontent.com/4a3180df1955abb6c5d5be361c354a7594a8e3ee8ec9b93ef55634dbc9ee5ec1/68747470733a2f2f7472617669732d63692e6f72672f666c75786f66742f6d696772616e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fluxoft/migrant)[![Latest Stable Version](https://camo.githubusercontent.com/bda81d484aa0c33aa013d79489b7e5eff1fa51945cc119c134a78843b44e602e/68747470733a2f2f706f7365722e707567782e6f72672f666c75786f66742f6d696772616e742f762f737461626c652e737667)](https://packagist.org/packages/fluxoft/migrant)[![Total Downloads](https://camo.githubusercontent.com/f50847ca988c2381d6b8fb627ce4dc0116cfe1835e1d87842a6885d4e2bef8b1/68747470733a2f2f706f7365722e707567782e6f72672f666c75786f66742f6d696772616e742f646f776e6c6f6164732e737667)](https://packagist.org/packages/fluxoft/migrant)[![Latest Unstable Version](https://camo.githubusercontent.com/f0e0a7572bfe6a9703410534a2183638e92bc199157f0467c5a05e669e77e6de/68747470733a2f2f706f7365722e707567782e6f72672f666c75786f66742f6d696772616e742f762f756e737461626c652e737667)](https://packagist.org/packages/fluxoft/migrant)[![License](https://camo.githubusercontent.com/757561f92a22423d1b9b4f431b41ae41e42d1d3f0b895348f8941dd31b95e56e/68747470733a2f2f706f7365722e707567782e6f72672f666c75786f66742f6d696772616e742f6c6963656e73652e737667)](https://packagist.org/packages/fluxoft/migrant)

Description
-----------

[](#description)

This is a simple database migration tool for automating versioning between copies of the same database on different environments.

The design goal for this package was to provide a easily memorable command-line interface for a program that would allow the developer to use native SQL code for the migrations themselves, including the ability to drop in the output from a database dump as the first migration and have that code execute properly.

Installation
------------

[](#installation)

Add the dependency.

```
{
	"require": {
		"fluxoft/migrant": "dev-master"
	}
}

```

Download the composer.phar

```
curl -sS https://getcomposer.org/installer | php

```

Install the library.

```
php composer.phar install

```

Usage
-----

[](#usage)

Once Migrant is installed in your Composer vendor directory for the project, you will just need to make a folder to keep your migration set up (I usually make a "db" folder at the same level as my "vendor" folder in the root of my project).

Migrant is used by passing it a series of command-line arguments. There are 5 recognized commands:

### init

[](#init)

To initialize your migrant directory:

```
../vendor/bin/migrant init

```

This will create a migrant.ini file where you will need to set up your database connections for your various environments and a migrations folder where new migrations are created.

### add

[](#add)

Next, either add a migration file manually or by using "migrant add" to create one in your migrations folder:

```
../vendor/bin/migrant add example

```

The command above will create a file named something like "migrations/20150219114901\_example.sql" with a blank migration template. Open that file and add the SQL that should be run for both the "up" and "down" migrations. Make sure to leave the line "`-- //@UNDO`" intact between the up and the down. If you create your own migration, keep in mind that the integer before the first slash is used as the sorting key, so if you use an integer with fewer characters than 14 (by default "migrant add" uses the year, month, date, hour, minute, and second as the sort value), migrations may appear out of order.

For instance, the following files:

```
drwxr-xr-x 2 www-data www-data 4096 Feb 19 16:53 ./
drwxr-xr-x 3 www-data www-data 4096 Feb 17 19:12 ../
-rw-r--r-- 1 www-data www-data  225 Feb 19 16:53 123_test.sql
-rw-r--r-- 1 www-data www-data  400 Feb 17 19:13 20150217191326_initial.sql
-rw-r--r-- 1 www-data www-data  235 Feb 17 19:21 20150217191656_second.sql
-rw-r--r-- 1 www-data www-data  225 Feb 19 16:53 321_test2.sql

```

Are actually executed in the following order:

```
root@vagrant-ubuntu-trusty-64:/websites/test.com/db2# ../vendor/bin/migrant status

The following migrations were found:
Revision            Filename                                           Migrated?
================================================================================
123                 123_test.sql                                              NO
321                 321_test2.sql                                             NO
20150217191326      20150217191326_initial.sql                                NO
20150217191656      20150217191656_second.sql                                 NO

```

### up

[](#up)

When you are ready to migrate, run the "up" command:

```
migrant up

```

This will run all available migrations against the "development" environment. To specify a different environment:

```
migrant up production

```

To migrate up to a specific revision number and no further:

```
migrant up 20150220123456

```

...or to this revision on the production environment:

```
migrant up 20150220123456 production

```

### down

[](#down)

If you need to roll back a migration, the "down" command works in much the same way as the "up" command:

```
migrant down

```

The key difference is that "down" will only roll back a single revision at a time unless a target revision is given:

```
migrant down 20141231235959

```

To roll back every migration, specify "0" as the target revision:

```
migrant down 0

```

As with "down" a specific environment can be given as the last argument:

```
migrant down testing

```

### status

[](#status)

To see all available migrations and to see which ones have been run, use the "status" command.

```
The following migrations were found:
Revision            Filename                                           Migrated?
================================================================================
123                 123_test.sql                                             YES
321                 321_test2.sql                                            YES
20150217191326      20150217191326_initial.sql                                NO
20150217191656      20150217191656_second.sql                                 NO

```

As with the other commands, this command will accept an environment name but runs against "development" by default:

```
migrant status production

```

### Help

[](#help)

To get the inline help, simply run migrant with no arguments:

```
root@vagrant-ubuntu-trusty-64:/var/www/db# ../vendor/bin/migrant

Usage:
  migrant  [] [ (default = "development")]

Available commands:

  init    Set up a fresh installation with default migrations directory
          and config files.
            "migrant init"

  add     Add a new migration with parameter
            "migrant add  []"

  up      Update the database to a specific revision, or using all
          available migrations.
            "migrant up [] []"

  down    Rollback the database by a single migration from its current state,
          or all revisions with a revision number higher than or equal to
          , or roll back every migration by passing  of 0.
            "migrant down [] []"

  status  Report on available versus installed migrations.
            "migrant status"

root@vagrant-ubuntu-trusty-64:/var/www/db#

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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

Unknown

Total

1

Last Release

936d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/752c7d73a901e4127eb085e33a61da585b8616b0effa0e9602fb52ea1d33c012?d=identicon)[avfletch](/maintainers/avfletch)

---

Top Contributors

[![joe-hart](https://avatars.githubusercontent.com/u/2655238?v=4)](https://github.com/joe-hart "joe-hart (4 commits)")[![marcfowler](https://avatars.githubusercontent.com/u/1171131?v=4)](https://github.com/marcfowler "marcfowler (2 commits)")

---

Tags

phpmigrationdatabasemigrant

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tcdev-migrant/health.svg)

```
[![Health](https://phpackages.com/badges/tcdev-migrant/health.svg)](https://phpackages.com/packages/tcdev-migrant)
```

###  Alternatives

[awssat/laravel-sync-migration

Laravel tool helps to sync migrations without refreshing the database

10923.2k](/packages/awssat-laravel-sync-migration)[modul-is/orm

Lightweight hybrid ORM/Explorer

1118.1k](/packages/modul-is-orm)[codengine/laravel-custom-migrations

Custom Migrations for Laravel

131.3k](/packages/codengine-laravel-custom-migrations)

PHPackages © 2026

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