This is a database migration library for PHP/MySQL. It mimics the behaviour of Ruby-on-Rails's database migration.
A database migration script is generated with a unique identifier. This means any person in your team can create a script independently, and, later in time, you guys can sync your scripts (with a source control or whatever) and update your database's structure with a single command.
- Create database
- Drop database
- Migrate database to the latest point
- Rollback one by one
- Get a SQL for your current schemas
config.phpand configure your MySQL stuffs.
- Create your database by
php migrate.php create
- Generate a migration script by
php migrate.php generate create_first_table
- Open your new migration script in the directiory
migrationand edit it.
up()is for the migrating action, and
down()is for the rollback action.
- Run migration with
php migrate.php up
php migrate.php dumpin order to generate a SQL for your current schemas.
- Rollback the latest migration with
php migrate.php down
- Drop the database with
php migrate.php drop
You might need to find where your PHP's binary located.
Examples of migration scripts are in the directory
- Let your Apache point to the root folder of this project somehow
chmod 777the directory
- Open your browser and point to
- Go to the
- Configure database's parameters for testing in the beginning of
- Run all tests by
If all tests are passed, you may start your modification and submit me a pull request.
Tanin Na Nakorn
It is under Tanin's license, which means you can do whatever with it.