migration
Introduction
YcheukfMigration is a db migration module for zend framework 2. It just like YII.
Project originally based on ZfSimpleMigrations, and support multiple db migration.
Only run at command line., (*1)
Features / Goals
- db migration like YII, ROR. (finished)
- mult db migration support. (finished)
Requirements
Installation
Install via git, (*2)
Clone this repo
git clone https://github.com/ycheukf/migration.git
, (*3)
Install via Composer, (*4)
Add this to your composer.json under "require":
"ycheukf/migration": "dev-master"
, (*5)
Run command:
php composer.phar update
, (*6)
Usage
1: add module 'YcheukfMigration' to your application.config.php, (*7)
return array(
'modules' => array(
'YcheukfMigration',
'Application',
),
);
2: get the helpinfo by running "php public/index.php", (*8)
Example
1: generate a new migration-file in path/migrations/default, (*9)
php public/index.php migration generate
2: apply a migration (upgrade or downgrade) ., (*10)
php public/index.php migration up db;
// or
php public/index.php migration down db;
"db" is the key of the db-config array, usually written at path/config/autoload/global.php, (*11)
return array(
'db' => array(//that is it
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=myzf2;host=localhost',
'username' => 'root',
'password' => 'root',
'driver_options' => array(
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
// ...
);
3: apply migration for all the db-array which is returned by an event "setDbConfigsFromEvent", (*12)
php public/index.php migration up --dbsfromevent
// or
php public/index.php migration down --dbsfromevent
4: apply migration for a key "db" of the db-array which is returned by an event "setDbConfigsFromEvent", (*13)
php public/index.php migration up db --dbsfromevent
// or
php public/index.php migration down db --dbsfromevent