LibMigration

The PHP database migration tool for MySQL.

View project onGitHub

Commands

phpmigrate is a executable command line interface of LibMigration.

syntax

phpmigrate [-h|-d|-f|-c] COMMAND

Command line Options

-d

Switch the debug mode to output log on the debug level.

Exsample:

$ phpmigrate -d
DEBUG >> Getting schema version from 'db1'
[db1] Current schema version is 0
[db1] Your migrations yet to be executed are below.

-h

List available command line options.

-f=FILE

Specify to load configuration file.

-c

List configurations.

Exsample:

$ phpmigrate -c
Configurations :
  [config_file]                        => migration.php
  [debug]                              =>
  [colors]                             => 1
  [databases/db1/database_dsn]         => mysql:dbname=yourdatabase;host=localhost
  [databases/db1/database_user]        => user
  [databases/db1/database_password]    => password
  [databases/db1/schema_version_table] => schema_version

commands

init

Create skeleton configuration file in the current working directory.

create NAME [DATABASENAME …]

Create new skeleton migration file.

Exsample:

$ phpmigrate create alter_table1
[db1] Created ./databases/db1/20130703025128_db1_alter_table1.php

status [DATABASENAME …]

List the migrations yet to be executed.

Exsample:

$ phpmigrate status
[db1] Current schema version is 0
[db1] Your migrations yet to be executed are below.
20130703020613_db1_migration1.php
20130703020616_db1_migration2.php
20130703020617_db1_migration3.php

migrate [DATABASENAME …]

Execute the next migrations up.

Exsample:

$ phpmigrate up
[db1] Current schema version is 0
[db1] Proccesing migrate up by 20130703020613_db1_migration1.php
[db1] Proccesing migrate up by 20130703020616_db1_migration2.php

up [DATABASENAME …]

Execute the next migration up.

down [DATABASENAME …]

Execute the next migration down.

Exsample:

$ phpmigrate down
[db1] Current schema version is 20130703020616
[db1] Proccesing migrate down to version 20130703020613 by 20130703020616_db1_migration2.php