Ladder

A (deprecated) PHP database migration tool.

Commands

Add

The add command allows a single migration to be added to the database, if it's not already been applied.

$ php ladder.php add 1

Create

The create command takes a single parameter - the name of the migration to create. Ladder will then create a migration file in the right location with the next logical migration number, and open it with your specified editor (configured in config/editor.php).

$ php ladder.php create users

Diff-Save

Diff-save saves the current database state to a local store (not in the database), allowing you to make changes to the schema, then later run the diff command.

$ php ladder.php diff-save

Diff

Running diff will load the previously-stored data, and compare the database to it. Ladder will then output migration code for any columns or indexes that have been added or removed.

Please note that at present, Ladder isn't clever enough to detect columns being renamed.

$ php ladder.php diff

Migrate

Running the migrate command will cause Ladder to check the database for which migrations have previously been applied, and run the up() method for any that are missing.

$ php ladder.php migrate

You can specify a migration number to stop at, allowing partial upgrade or downgrades of the database.

$ php ladder.php migrate 15

Reapply

The reapply command requires a single argument; the migration to reapply. If the specified migration hasn't yet been applied, it is simply applied and no further action is taken. If the migration has already been applied, then it is first removed (via its down() method), then added back again.

$ php ladder.php reapply 15

Remove

The remove command allows a single migration to be removed from the database.

$ php ladder.php remove 15

Status

The status command shows the current status of each configured database. Passing --verbose will show which specific migrations have not been applied. A '<' symbol shows the database is behind the migrations, an '=' sign means you are up-to-date, and a '!' means something is wrong.

$ php ladder.php status $ php ladder.php status --verbose

Verify

The verify command will remove any reference to migrations that don't exist from the database. This may happen when you are experimenting and decide a certain migration just doesn't cut it. After you've deleted the migration file, run verify.

$ php ladder.php verify

Version

The version command simply displays the version number of Ladder that you are currently using.

$ php ladder.php version