定制 masom/lhm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

masom/lhm

最新稳定版本:0.5.1

Composer 安装命令:

composer require masom/lhm

包简介

Large Hadron Migrator for phinx

README 文档

README

Build Status

Large Hadron Migrator

Phinx meets LHM

This is a PHP port of https://github.com/soundcloud/lhm . lhm_php supports primary keys with a name other than id.

Version 0.4.0 is considered "production-ready". It is in use at PopKey.co to migrate millions of records.

TODO

  • [SqlHelper] Support column renames
  • [LHM] Support cleanup
  • [Chunker] data limits/filtering
  • [Chunker] throttle
  • [Switchers] Locked switcher
  • add index / remove index

Usage

<?php

use Phinx\Migration\AbstractMigration;


class DropLargeColumns extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        /**
         * Uncomment this to see logs.
         * $logger = new Monolog\Logger('test', [new \Monolog\Handler\StreamHandler('php://stdout')]);
         * \Lhm\Lhm::setLogger($logger);
         */
        \Lhm\Lhm::setAdapter($this->getAdapter());
        \Lhm\Lhm::changeTable('characters', function (Phinx\Db\Table $table) {
            $table
                ->removeColumn('alternate_name')
                ->removeColumn('alternate_bio')
                ->removeColumn('alternate_storyline')
                ->save();
        });
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        \Lhm\Lhm::setAdapter($this->getAdapter());
        \Lhm\Lhm::changeTable('characters', function (Phinx\Db\Table $table) {
            $table
                ->addColumn('alternate_name', 'string', ['limit' => 255, 'null' => true, 'default' => null])
                ->addColumn('alternate_bio', 'string', ['limit' => 255, 'null' => true, 'default' => null])
                ->addColumn('alternate_storyline', 'string', ['limit' => 255, 'null' => true, 'default' => null])
                ->save();
        });
    }
}

Cleanup

If there is an error while LHM is running a few triggers and tables might be left in the database.

bin/lhm command will let you clean your database.

It executes a dry-run unless the --run option is specified.

Large Hadron Migrator version 0.4.0

Usage:
 cleanup [-c|--configuration="..."] [-p|--parser="..."] [-e|--environment="..."] [-r|--run] [-u|--until="..."]

Options:
 --configuration (-c)  The configuration file to load
 --parser (-p)         Parser used to read the config file. Defaults to YAML
 --environment (-e)    The target environment
 --run (-r)            Apply the cleanup operations.
 --until (-u)          Drop archive tables older than the specified date at UTC (YYYY-MM-DD_hh:mm:ss).
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message

Help:

 Cleanup LHM tables, old archives and triggers. Defaults to a dry-run unless --run is specified.

AWS Considerations

Amazon RDS disables log_bin_trust_function_creators by default.

See soundcloud/lhm#76 and soundcloud/lhm#65

If your database instance is running a custom parameter group:
  1. Open the RDS web console.
  2. Open the “Parameter Groups” tab.
  3. Create a new Parameter Group. On the dialog, select the MySQL family compatible to your MySQL database version, give it a name and confirm.
  4. Select the just created Parameter Group and issue “Edit Parameters”.
  5. Look for the parameter ‘log_bin_trust_function_creators’ and set its value to ‘1’.
  6. Save the changes.

The changes to the parameter group will be applied immediately.

If your database instance is running on the default parameter group:
  1. Open the RDS web console.
  2. Open the “Parameter Groups” tab.
  3. Create a new Parameter Group. On the dialog, select the MySQL family compatible to your MySQL database version, give it a name and confirm.
  4. Select the just created Parameter Group and issue “Edit Parameters”.
  5. Look for the parameter ‘log_bin_trust_function_creators’ and set its value to ‘1’.
  6. Save the changes.
  7. Open the “Instances” tab. Expand your MySQL instance and issue the “Instance Action” named “Modify”.
  8. Select the just created Parameter Group and enable “Apply Immediately”.
  9. Click on “Continue” and confirm the changes.
  10. Open the “Instances” tab. Expand your MySQL instance and issue the “Instance Action” named “Reboot”.

source: https://techtavern.wordpress.com/2013/06/17/mysql-triggers-and-amazon-rds/

统计信息

  • 总下载量: 9.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 31
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-04-28