jinnguyen / puja-migration
Puja-Migration 是一个数据库迁移 PHP 库,支持文件 SQL 和 PHP
v1.1.0
2017-01-21 04:15 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-23 15:51:12 UTC
README
Puja-Migration 是一个数据库迁移 PHP 库,支持文件 SQL 和 PHP
安装
composer require jinnguyen/puja-migration
使用
include '/path/to/vendor/autoload.php'; use Puja\Migration\Migrate;
示例
// 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. ));
注意*
1. 迁移文件的顺序非常重要
请按照文件名规则进行排序:- 文件名应以数字开头,例如: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. 默认情况下,PHP 文件不会显示日志消息,如果您想显示日志消息,可以使用 $this->addStament('Message'); // 在demo/3.php中查看