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.
It supports:
- Create database
- Drop database
- Migrate database to the latest point
- Rollback one by one
- Get a SQL for your current schemas
- Open
config.php
and 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
migration
and edit it.up()
is for the migrating action, anddown()
is for the rollback action. - Run migration with
php migrate.php up
- Run
php migrate.php dump
in 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 migration_example
.
- Let your Apache point to the root folder of this project somehow
chmod 777
the directorymigration
andschema
- Open your browser and point to
index.php
- Go to the
test
folder. - Configure database's parameters for testing in the beginning of
test.php
- Run all tests by
php test.php
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.