コード例 #1
0
 /**
  * Determines what action should be performed and takes that action.
  *
  * @uses MpmDownController::displayHelp()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::writeHeader()
  * @uses MpmMigrationHelper::getListOfMigrations()
  * @uses MpmMigrationHelper::getCurrentMigrationNumber()
  * @uses MpmMigrationHelper::getTimestampFromId()
  * @uses MpmMigrationHelper::runMigration()
  * @uses MpmMigrationHelper::setCurrentMigration()
  * 
  * @return void
  */
 public function doAction($quiet = false)
 {
     // write the header
     $clw = MpmCommandLineWriter::getInstance();
     $skip_headers = false;
     if (!empty($this->arguments[2])) {
         $skip_headers = true;
     }
     if (!$quiet && !$skip_headers) {
         $clw->writeHeader();
     }
     // correct number of command line arguments?
     if (count($this->arguments) == 0) {
         return $this->displayHelp();
     }
     // ID of the migration we are going down to
     $down_to = $this->arguments[0];
     if (!is_numeric($down_to)) {
         return $this->displayHelp();
     }
     if ($down_to == 0) {
         $down_to = -1;
     }
     // are we forcing this?
     $forced = false;
     if (isset($this->arguments[1]) && strcasecmp($this->arguments[1], '--force') == 0) {
         $forced = true;
     }
     // get list of migrations and the current migration number
     $list = MpmMigrationHelper::getListOfMigrations($down_to, 'down');
     $total = count($list);
     $current = MpmMigrationHelper::getCurrentMigrationNumber();
     if ($down_to == '-1') {
         if (!$quiet) {
             echo "Removing all migrations... ";
         }
         $down_to = 0;
     } else {
         if (!$quiet) {
             echo "Migrating to " . MpmMigrationHelper::getTimestampFromId($down_to) . ' (ID ' . $down_to . ')... ';
         }
     }
     foreach ($list as $id => $obj) {
         MpmMigrationHelper::runMigration($obj, 'down', $forced);
     }
     MpmMigrationHelper::setCurrentMigration($down_to);
     if (!$skip_headers && !$quiet) {
         echo "\n";
         $clw->writeFooter();
     }
 }
コード例 #2
0
 /**
  * Determines what action should be performed and takes that action.
  *
  * @uses MpmUpController::displayHelp()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::writeHeader()
  * @uses MpmCommandLineWriter::writeFooter()
  * @uses MpmMigrationHelper::getListOfMigrations()
  * @uses MpmMigrationHelper::getTimestampFromId()
  * @uses MpmMigrationHelper::runMigration()
  * @uses MpmMigrationHelper::setCurrentMigration
  * 
  * @param bool $quiet suppresses certain text when true
  *
  * @return void
  */
 public function doAction($quiet = false)
 {
     $clw = MpmCommandLineWriter::getInstance();
     $skip_headers = false;
     if (!empty($this->arguments[2])) {
         $skip_headers = true;
     }
     if (!$quiet && !$skip_headers) {
         $clw->writeHeader();
     }
     if (count($this->arguments) == 0) {
         return $this->displayHelp();
     }
     $up_to = $this->arguments[0];
     if (!is_numeric($up_to)) {
         return $this->displayHelp();
     }
     // are we forcing this?
     $forced = false;
     if (isset($this->arguments[1]) && strcasecmp($this->arguments[1], '--force') == 0) {
         $forced = true;
     }
     // what migrations need to be done?
     $list = MpmMigrationHelper::getListOfMigrations($up_to);
     if (count($list) == 0) {
         if (!$quiet) {
             echo "\nAll needed migrations have already been run or no migrations exist.";
             if (!$skip_headers) {
                 $clw->writeFooter();
             }
             return;
         } else {
             return;
         }
     }
     $to = MpmMigrationHelper::getTimestampFromId($up_to);
     if (!$quiet) {
         echo "\nMigrating to " . $to . ' (ID ' . $up_to . ')... ';
     }
     foreach ($list as $id => $obj) {
         MpmMigrationHelper::runMigration($obj, 'up', $forced);
     }
     MpmMigrationHelper::setCurrentMigration($up_to);
     if (!$quiet && !$skip_headers) {
         $clw->writeFooter();
     }
 }
コード例 #3
0
 /**
  * Determines what action should be performed and takes that action.
  *
  * @uses MpmUpController::displayHelp()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::writeHeader()
  * @uses MpmCommandLineWriter::writeFooter()
  * @uses MpmMigrationHelper::getListOfMigrations()
  * @uses MpmMigrationHelper::getTimestampFromId()
  * @uses MpmMigrationHelper::runMigration()
  * @uses MpmMigrationHelper::setCurrentMigration
  *
  * @param bool $quiet supresses certain text when true
  *
  * @return void
  */
 public function doAction($quiet = false)
 {
     $clw = MpmCommandLineWriter::getInstance();
     if (!$quiet) {
         $clw->writeHeader();
     }
     if (count($this->arguments) == 0) {
         return $this->displayHelp();
     }
     $up_to = $this->arguments[0];
     if (!is_numeric($up_to)) {
         return $this->displayHelp();
     }
     // parse other optional arguments
     list($forced, $dryrun) = $this->parse_options($this->arguments);
     // what migrations need to be done?
     $list = MpmMigrationHelper::getListOfMigrations($up_to);
     if (count($list) == 0) {
         if (!$quiet) {
             echo 'All needed migrations have already been run or no migrations exist.';
             $clw->writeFooter();
             exit;
         } else {
             return;
         }
     }
     $to = MpmMigrationHelper::getTimestampFromId($up_to);
     if (!$quiet) {
         echo "Migrating to " . $to . ' (ID ' . $up_to . ')... ';
     }
     foreach ($list as $id => $obj) {
         MpmMigrationHelper::runMigration($obj, 'up', array('forced' => $forced, 'dryrun' => $dryrun));
     }
     MpmMigrationHelper::setCurrentMigration($up_to, $dryrun);
     if (!$quiet) {
         echo "\n";
         $clw->writeFooter();
     }
 }
コード例 #4
0
 /**
  * Determines what action should be performed and takes that action.
  *
  * @uses MpmDownController::displayHelp()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::writeHeader()
  * @uses MpmMigrationHelper::getListOfMigrations()
  * @uses MpmMigrationHelper::getCurrentMigrationNumber()
  * @uses MpmMigrationHelper::getTimestampFromId()
  * @uses MpmMigrationHelper::runMigration()
  * @uses MpmMigrationHelper::setCurrentMigration()
  * 
  * @return void
  */
 public function doAction()
 {
     // write the header
     $clw = MpmCommandLineWriter::getInstance();
     $clw->writeHeader();
     // correct number of command line arguments?
     if (count($this->arguments) == 0) {
         return $this->displayHelp();
     }
     // ID of the migration we are going down to
     $down_to = $this->arguments[0];
     if (!is_numeric($down_to)) {
         return $this->displayHelp();
     }
     if ($down_to == 0) {
         $down_to = -1;
     }
     // parse other optional arguments
     list($forced, $dryrun) = $this->parse_options($this->arguments);
     // get list of migrations and the current migration number
     $list = MpmMigrationHelper::getListOfMigrations($down_to, 'down');
     $total = count($list);
     $current = MpmMigrationHelper::getCurrentMigrationNumber();
     if ($down_to == '-1') {
         echo "Removing all migrations... ";
         $down_to = 0;
     } else {
         echo "Migrating to " . MpmMigrationHelper::getTimestampFromId($down_to) . ' (ID ' . $down_to . ')... ';
     }
     foreach ($list as $id => $obj) {
         MpmMigrationHelper::runMigration($obj, 'down', array('forced' => $forced, 'dryrun' => $dryrun));
     }
     MpmMigrationHelper::setCurrentMigration($down_to, $dryrun);
     echo "\n";
     $clw->writeFooter();
 }