Exemplo n.º 1
0
 /**
  * Clears the migrations table and then rebuilds it.
  *
  * @uses MpmListHelper::mergeFilesWithDb()
  * @uses MpmDbHelper::doSingleRowSelect()
  *
  * @return void
  */
 public function reloadMigrations()
 {
     echo 'Clearing out existing migration data... ';
     $this->dbObj->exec('TRUNCATE TABLE `mpm_migrations`');
     echo 'done.', "\n\n", 'Rebuilding migration data... ';
     MpmListHelper::mergeFilesWithDb();
     echo 'done.', "\n";
     if ($this->initialMigrationTimestamp != null) {
         echo "\n", 'Updating initial migration timestamp to ', $this->initialMigrationTimestamp, '... ';
         $result = MpmDbHelper::doSingleRowSelect('SELECT COUNT(*) AS total FROM `mpm_migrations` WHERE `timestamp` = "' . $this->initialMigrationTimestamp . '"', $this->dbObj);
         if ($result->total == 1) {
             $this->dbObj->exec('UPDATE `mpm_migrations` SET `is_current` = 0');
             $this->dbObj->exec('UPDATE `mpm_migrations` SET `is_current` = 1 WHERE `timestamp` = "' . $this->initialMigrationTimestamp . '"');
             $this->dbObj->exec('UPDATE `mpm_migrations` SET `active` = 1 WHERE `timestamp` <= "' . $this->initialMigrationTimestamp . '"');
         }
         echo 'done.', "\n";
     }
 }