コード例 #1
0
ファイル: Lhm.php プロジェクト: tristanpemble/lhm_php
 /**
  * @param $name
  * @param callable $operations
  * @param array $options
  *                      - `stride` integer
  *                          Size of a chunk (defaults to 2000)
  *                      - `atomic_switch` boolean
  *                          Enable atomic switching (defaults to true)
  *                      - `retry_sleep_time` integer
  *                          How long should the switch wait until retrying ( defaults to 10 )
  *                      - `max_retries` integer
  *                          How many times the switch should be attempted ( defaults to 600 )
  *                      - `archive_name` string
  *                          Name of the archive table ( defaults to 'lhma_' . gmdate('Y_m_d_H_i_s') . "_{$origin->getName()}" )
  *
  */
 public static function changeTable($name, callable $operations, array $options = [])
 {
     if (!static::getAdapter()) {
         throw new \RuntimeException(__CLASS__ . ' must have an adapter set. Call ' . __CLASS__ . '::setAdapter()');
     }
     $invoker = new Invoker(static::$adapter, new \Phinx\Db\Table($name, [], static::getAdapter()), $options);
     $invoker->setLogger(static::getLogger());
     $invoker->execute($operations);
 }
コード例 #2
0
 protected function setUp()
 {
     parent::setUp();
     $this->adapter->execute("SET GLOBAL innodb_lock_wait_timeout=3");
     $this->adapter->execute("SET GLOBAL lock_wait_timeout=3");
     $this->origin = new \Phinx\Db\Table('ponies');
     $migration = new InitialMigration(time());
     $migration->setAdapter($this->adapter);
     $migration->up();
     $invoker = new Invoker($this->adapter, $this->origin);
     $this->destination = $invoker->temporaryTable();
     $this->switcher = new LockedSwitcher($this->adapter, $this->origin, $this->destination);
 }