/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $database_dir = sfConfig::get('sf_data_dir'); $default_updater_configuration_file = $database_dir . '/updater-configuration.xml'; $bare_database_target = $arguments['bare-database-target']; $xml_updater_configuration = new \sfAltumoPlugin\Deployment\DatabaseUpdaterConfigurationFile($default_updater_configuration_file); $xml_updater_configuration->setDatabaseDirectory($database_dir); $bare_database_loader = new \sfAltumoPlugin\Deployment\BareDatabaseLoader($xml_updater_configuration); // First reload propel sql files $this->log("\nReloading Propel SQL files\n"); \Altumo\Utils\Shell::runWithPipedOutput(sfConfig::get('sf_root_dir') . '/symfony propel:build-sql'); // Load bare database $this->log("\nApplying to bare database\n"); $commands_executed = $bare_database_loader->loadBareDatabase(); foreach ($commands_executed as $command) { $this->logSection('sh', $command); } $this->log("\nA fresh Propel database has been loaded to the bare database.\n"); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $database_dir = sfConfig::get('sf_data_dir'); $default_build_sequence_file = $database_dir . '/build-sequence.xml'; $default_update_log_file = $database_dir . '/update-log.xml'; $default_updater_configuration_file = $database_dir . '/updater-configuration.xml'; $command = $arguments['command']; //initialize updater, if there is meaningful work to do if (in_array($command, array('update', 'drop'))) { $xml_build_sequence = new \sfAltumoPlugin\Build\DatabaseBuildSequenceFile($default_build_sequence_file); $xml_sf_altumo_build_sequence = new \sfAltumoPlugin\Build\DatabaseBuildSequenceFile($database_dir . '/../plugins/sfAltumoPlugin/data/build-sequence.xml'); $xml_update_log = new \sfAltumoPlugin\Deployment\DatabaseUpdateLogFile($default_update_log_file, false); $xml_updater_configuration = new \sfAltumoPlugin\Deployment\DatabaseUpdaterConfigurationFile($default_updater_configuration_file); $xml_updater_configuration->setDatabaseDirectory($database_dir); $database_updater = new \sfAltumoPlugin\Deployment\DatabaseUpdater($xml_updater_configuration, $xml_build_sequence, $xml_update_log, $xml_sf_altumo_build_sequence); } switch ($command) { case 'update': $ignore_working_tree_changes = \Altumo\Validation\Booleans::assertLooseBoolean($options['ignore-working-tree-changes']); $has_upcoming_data_updates = $database_updater->hasUpcomingDataUpdates(); if ($has_upcoming_data_updates && \Altumo\Git\Status::hasChanges() && !$ignore_working_tree_changes) { throw new \Exception('Your working tree currently has changes. You must commit or stage these before performing an update or pass the ignore-working-tree-changes flag.'); } $number_of_scripts_executed = $database_updater->update($arguments); break; case 'drop': $number_of_scripts_executed = $database_updater->drop($arguments); break; case 'init': $xml_updater_configuration = new \sfAltumoPlugin\Deployment\DatabaseUpdaterConfigurationFile($default_updater_configuration_file, false); $xml_update_log = new \sfAltumoPlugin\Deployment\DatabaseUpdateLogFile($default_update_log_file, false); $number_of_scripts_executed = 0; break; default: throw new sfCommandException(sprintf('Command "%s" does not exist.', $arguments['command'])); } $this->log($number_of_scripts_executed . ' scripts executed successfully.' . "\n"); }