/** * Does the actual task of destroying and rebuilding the database from the ground up. * * @uses MpmSchema::destroy() * @uses MpmSchema::reloadMigrations() * @uses MpmSchema::build() * @uses MpmLatestController::doAction() * @uses MPM_DB_PATH * * @param bool $with_data whether or not to run the test_data.php file after build * * @return void */ public function build($with_data) { require_once MPM_DB_PATH . 'schema.php'; $obj = new MpmInitialSchema(); $obj->destroy(); echo "\n"; $obj->reloadMigrations(); echo "\n", 'Building initial database schema... '; $obj->build(); echo 'done.', "\n\n", 'Applying migrations... '; try { $total_migrations = MpmMigrationHelper::getMigrationCount(); if ($total_migrations == 0) { echo "no migrations exist."; } else { $to_id = MpmMigrationHelper::getLatestMigration(); $obj = new MpmUpController('up', array($to_id, $forced)); $obj->doAction($quiet); } } catch (Exception $e) { echo "\n\nERROR: " . $e->getMessage() . "\n\n"; exit; } if ($with_data) { require_once MPM_DB_PATH . 'test_data.php'; echo "\n\nInserting test data... "; $test_data_obj = new MpmTestData(); $test_data_obj->build(); echo 'done.'; } echo "\n\n", 'Database build complete.', "\n"; }
/** * Does the actual task of destroying and rebuilding the database from the ground up. * * @uses MpmSchema::destroy() * @uses MpmSchema::reloadMigrations() * @uses MpmSchema::build() * @uses MpmLatestController::doAction() * @uses MPM_DB_PATH * @param bool $with_data whether or not to run the test_data.php file after build */ public function build($with_data = false) { // parse other optional arguments list($forced, $dryrun) = $this->parse_options($this->arguments); require_once MPM_DB_PATH . 'schema.php'; $obj = new MpmInitialSchema($dryrun); $obj->destroy(); echo "\n"; $obj->reloadMigrations(); if (!$dryrun) { echo "\n", 'Building initial database schema... '; $obj->build(); echo 'done.', "\n\n", 'Applying migrations... '; } try { $total_migrations = MpmMigrationHelper::getMigrationCount(); if ($total_migrations == 0) { echo "no migrations exist."; } else { $to_id = MpmMigrationHelper::getLatestMigration(); $obj = new MpmUpController('up', array_merge(array($to_id), $this->arguments)); $obj->doAction(); } } catch (Exception $e) { echo "\n\nERROR: " . $e->getMessage() . "\n\n"; exit; } if (!$dryrun && $with_data) { require_once MPM_DB_PATH . 'test_data.php'; echo "\n\nInserting test data... "; $test_data_obj = new MpmTestData(); $test_data_obj->build(); echo 'done.'; } echo "\n\n", 'Database build complete.', "\n"; }
/** * Does the actual task of destroying and rebuilding the database from the ground up. * * @uses MpmSchema::destroy() * @uses MpmSchema::reloadMigrations() * @uses MpmSchema::build() * @uses MpmLatestController::doAction() * @uses MPM_DB_PATH * * @param bool $with_data whether or not to run the test_data.php file after build * * @return void */ public function build($with_data) { require_once MPM_DB_PATH . 'schema.php'; $obj = new MpmInitialSchema(); $obj->destroy(); echo "\n"; $obj->reloadMigrations(); echo "\n", 'Building initial database schema... '; $obj->build(); echo 'done.', "\n\n", 'Applying migrations... '; $obj = new MpmLatestController(); $obj->doAction(true); if ($with_data) { require_once MPM_DB_PATH . 'test_data.php'; echo "\n\nInserting test data... "; $test_data_obj = new MpmTestData(); $test_data_obj->build(); echo 'done.'; } echo "\n\n", 'Database build complete.', "\n"; }