jinnguyen/puja-migration

Puja-Migration is a database migration php library, supports both file sql and php

v1.1.0 2017-01-21 04:15 UTC

This package is not auto-updated.

Last update: 2024-04-22 13:41:16 UTC


README

Puja-Migration is a database migration php library, supports both file sql and php

Install:

composer require jinnguyen/puja-migration

Usage:

include '/path/to/vendor/autoload.php';
use Puja\Migration\Migrate;

Example:

// Configure DB
use Puja\Db\Adapter;

new \Puja\Db\Adapter(array(
    'write_adapter_name' => 'master',
    'adapters' => array(
        'default' => array(
            'host' => 'localhost',
            'username' => 'root',
            'password' => '123',
            'dbname' => 'fwcms',
            'charset' => 'utf8',
        ),
        'master' => array(
            'host' => 'localhost',
            'username' => 'root',
            'password' => '123',
            'dbname' => 'fwcms',
            'charset' => 'utf8',
        )
    )
));

// configure migration
new \Puja\Migration\Migrate(array(
    'table' => 'puja_migration', // db table name that store migration tracking information
    'dir' => __DIR__ . '/migrations/', // the folder store migration files
    'create_table' => true, // if true, the query "CREATE TABLE <table>" will run, should enable at the first time and disable from second time.
));

Note*

1. THE ORDER OF MIGRATION FILES ARE VERY IMPORTANT


So pls follow the file name conversation: - The name should begin by a numeric, e.g: 0-launched-project.sql, 1-update.sql, 2-data-fix.php,....
As above example,  0-launched-project.sql is  run first then 1-update.sql then 2-data-fix.php

2. The php files are not show log message as default, if you want to show the log message you can use $this->addStament('Message'); // check in demo/3.php