Beispiel #1
0
 public function afterAction($action, $params, $exitCode = 0)
 {
     $content = ob_get_clean();
     echo $content;
     Yii::log($content, CLogger::LEVEL_INFO, 'command.migrate');
     return parent::afterAction($action, $params, $exitCode);
 }
 /**
  * Migrate down.
  *
  * @param int $amount Number of reverted migrations.
  *
  * @return static
  * @since 0.1.0
  */
 public function revertMigrations($amount = 1)
 {
     $this->_mute();
     $this->_command->actionDown(array($amount));
     $this->_unmute();
     return $this;
 }
 protected function instantiateMigration($class)
 {
     $migration = parent::instantiateMigration($class);
     if ($this->testdata && $migration instanceof OEMigration) {
         $migration->setTestData(true);
         echo "\nRunning in testdata mode";
     }
     return $migration;
 }
 protected function getNewMigrations()
 {
     if (!$this->module) {
         $migrations = parent::getNewMigrations();
     } else {
         $migrations = array();
     }
     $module = $this->module ?: true;
     $applied = array();
     foreach ($this->getMigrationHistory(-1, $module) as $version => $time) {
         if (preg_match('@^(.+:)m(\\d{6}_\\d{6})_@', $version, $matches)) {
             $applied[$matches[1] . $matches[2]] = true;
         }
     }
     if (is_array($this->moduleMigrationPaths)) {
         foreach ($this->moduleMigrationPaths as $module => $modulePath) {
             $migrations = array_merge($migrations, $this->_getModuleMigrations($module, $applied));
         }
     }
     usort($migrations, function ($a, $b) {
         if (preg_match('@m(\\d{6}_\\d{6})@', $a, $matches)) {
             $a = $matches[1];
         }
         if (preg_match('@m(\\d{6}_\\d{6})@', $b, $matches)) {
             $b = $matches[1];
         }
         if ($a < $b) {
             return -1;
         } elseif ($a > $b) {
             return 1;
         }
         return 0;
     });
     return $migrations;
 }
Beispiel #5
0
 protected function getTemplate()
 {
     if ($this->templateFile !== null) {
         return parent::getTemplate();
     } else {
         return str_replace('CDbMigration', 'EDbMigration', parent::getTemplate());
     }
 }
 /**
  * Mark this database as past the initial data loading, used for an upgrade.
  *
  * @param $args
  * @return void
  */
 public function actionMark($args)
 {
     $args = array('m140411_120957_load_misc');
     parent::actionMark($args);
 }
Beispiel #7
0
 public function run($args)
 {
     parent::run($args);
     $this->flushCache();
 }
Beispiel #8
0
    public function getHelp()
    {
        return parent::getHelp() . <<<EOD

EXTENDED USAGE EXAMPLES (with modules)
  for every action except create you can specify the modules to use
  with the parameter --module=<modulenames>
  where <modulenames> is a comma seperated list of module names (or a single name)

 * yiic migrate create modulename create_user_table
   Creates a new migration named 'create_user_table' in module 'modulename'.

  all other commands work exactly as described above.

  command 'to' is not yet available.

EOD;
    }
 protected function getTemplate()
 {
     if ($this->templateFile !== null) {
         $path = Yii::getPathOfAlias($this->templateFile);
         if (is_file($path . '.php')) {
             return file_get_contents($path . '.php');
         } elseif (is_file($path . '.tpl')) {
             return file_get_contents($path . '.tpl');
         } else {
             $this->templateFile = null;
         }
     }
     return parent::getTemplate();
 }
 /**
  * Apply a single database upgrade step.
  *
  * @param $args
  * @return void
  */
 public function actionUp($args)
 {
     $component = $this->connectionID;
     switch ($this->hosting) {
         case 'S':
             $intVer = Yii::app()->{$component}->createCommand("SELECT key_value FROM xlsws_configuration WHERE `key_name` = 'DATABASE_SCHEMA_VERSION'")->queryScalar();
             if ($intVer !== false && (int) $intVer < 447) {
                 // Override certain migrations to support legacy schema order
                 $this->migrationPath = Yii::getPathOfAlias('application.migrations.legacy');
                 // Execute yii migrations
                 parent::actionUp($args);
                 // Point to standard migrations for next migration leg
                 $this->migrationPath = Yii::getPathOfAlias('application.migrations');
                 // Reset migration position to non-legacy
                 Yii::app()->{$component}->createCommand()->truncateTable('xlsws_migrations');
                 $this->actionMark(array('m140429_224114_update_configuration'));
             }
             parent::actionUp($args);
             Yii::app()->{$component}->createCommand("UPDATE xlsws_configuration SET `key_value` = 1 WHERE `key_name` = 'LIGHTSPEED_HOSTING'")->execute();
             Yii::app()->{$component}->createCommand("UPDATE xlsws_configuration SET `key_value` = 1 WHERE `key_name` = 'ENABLE_SSL'")->execute();
             break;
         case 'M':
         case 'T':
             parent::actionUp($args);
             Yii::app()->{$component}->createCommand("UPDATE xlsws_configuration SET `key_value` = 1 WHERE `key_name` = 'LIGHTSPEED_MT'")->execute();
             Yii::app()->{$component}->createCommand("UPDATE xlsws_configuration SET `key_value` = 1 WHERE `key_name` = 'LIGHTSPEED_HOSTING'")->execute();
             Yii::app()->{$component}->createCommand("UPDATE xlsws_configuration SET `key_value` = 1 WHERE `key_name` = 'ENABLE_SSL'")->execute();
             break;
         case 'N':
             // yiic hostingmigrate up --hosted=N === yiic migrate up
             // i.e. if no command line arguments defining a specific database
             // are present, this does the same thing as yiic migrate up
             parent::actionUp($args);
             break;
     }
 }
 /**
  * Apply a single database upgrade step.
  *
  * @param $args
  * @return void
  */
 public function actionUp($args)
 {
     $args = array(1);
     parent::actionUp($args);
 }
 /**
  * Mark this database as past the initial data loading, used for an upgrade.
  *
  * @param $args
  * @return void
  */
 public function actionMark($args)
 {
     $args = array('m140430_200509_ship_pay_cc_updates');
     parent::actionMark($args);
 }