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";
     }
 }
Exemplo n.º 2
0
 /**
  * Clears the migrations table and then rebuilds it.
  *
  * @uses MpmListHelper::mergeFilesWithDb()
  * @uses MpmDbHelper::doSingleRowSelect()
  *
  * @return void
  */
 public function reloadMigrations()
 {
     if ($this->dryrun) {
         echo "No clear out existing migration data for dry-run.\n";
     } else {
         $db_config = MpmDbHelper::get_db_config();
         $migrations_table = $db_config->migrations_table;
         echo 'Clearing out existing migration data... ';
         $this->dbObj->internal_exec('TRUNCATE TABLE `' . $migrations_table . '`');
         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 `' . $migrations_table . '` WHERE `timestamp` = "' . $this->initialMigrationTimestamp . '"', $this->dbObj);
             if ($result->total == 1) {
                 $this->dbObj->internal_exec('UPDATE `' . $migrations_table . '` SET `is_current` = 0');
                 $this->dbObj->internal_exec('UPDATE `' . $migrations_table . '` SET `is_current` = 1 WHERE `timestamp` = "' . $this->initialMigrationTimestamp . '"');
                 $this->dbObj->internal_exec('UPDATE `' . $migrations_table . '` SET `active` = 1 WHERE `timestamp` <= "' . $this->initialMigrationTimestamp . '"');
             }
             echo 'done.', "\n";
         }
     }
 }