protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rc = 0;
     try {
         if (!$input->getOption('force')) {
             if (!$input->isInteractive()) {
                 throw new Exception("You have to specify the --force option in order to run this command");
             }
             $confirmQuestion = new ConfirmationQuestion('Are you sure you want to update this concrete5 installation?');
             if (!$this->getHelper('question')->ask($input, $output, $confirmQuestion)) {
                 throw new Exception("Operation aborted.");
             }
         }
         $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
         $output = new ConsoleOutput();
         $configuration->setOutputWriter(new OutputWriter(function ($message) use($output) {
             $output->writeln($message);
         }));
         Update::updateToCurrentVersion($configuration);
     } catch (Exception $x) {
         $output->writeln('<error>' . $x->getMessage() . '</error>');
         $rc = 1;
     }
     return $rc;
 }
 public function submit()
 {
     if ($this->validateAction()) {
         try {
             $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
             $migrations = $configuration->getMigrationsToExecute('up', $configuration->getLatestVersion());
             foreach ($migrations as $migration) {
                 $migration->execute('up');
             }
             $this->set('success', t('Upgrade to <b>%s</b> complete!', APP_VERSION));
             \Config::save('concrete.version_installed', APP_VERSION);
         } catch (\Exception $e) {
             $this->set('error', $e);
         }
     }
 }
 public function testUpdate()
 {
     $db = Database::get();
     $this->assertTrue($db->tableExists('Files'));
     $sm = $db->getSchemaManager();
     $directory = dirname(__FILE__) . '/fixtures/';
     $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
     $configuration->setMigrationsDirectory($directory);
     $configuration->registerMigrationsFromDirectory($directory);
     $migrations = $configuration->getMigrations();
     $originalLogs = $sm->listTableDetails('Logs');
     $this->assertEquals(2, count($migrations));
     $this->assertTrue(array_key_exists('20140908071333', $migrations));
     $this->assertInstanceOf('\\Doctrine\\DBAL\\Migrations\\Version', $migrations['20140908071333']);
     $migrations = $configuration->getMigrationsToExecute('up', '20140908095447');
     $this->assertEquals(2, count($migrations));
     $migrations = $configuration->getMigrationsToExecute('up', '20140908071333');
     $this->assertEquals(1, count($migrations));
     $migration = $migrations['20140908071333'];
     $migration->execute('up');
     $newLogs = $sm->listTableDetails('Logs');
     $fPassword = $sm->listTableDetails('Files')->getColumn('fPassword');
     $this->assertFalse($originalLogs->hasColumn('testcolumn'));
     $this->assertTrue($newLogs->hasColumn('testcolumn'));
     $this->assertInstanceof('\\Doctrine\\DBAL\\Types\\TextType', $fPassword->getType());
     $migration->execute('down');
     $fPassword = $sm->listTableDetails('Files')->getColumn('fPassword');
     $newLogs = $sm->listTableDetails('Logs');
     $this->assertInstanceof('\\Doctrine\\DBAL\\Types\\StringType', $fPassword->getType());
     $this->assertFalse($newLogs->hasColumn('testcolumn'));
     $migrations = $configuration->getMigrationsToExecute('up', '20140908095447');
     foreach ($migrations as $migration) {
         $migration->execute('up');
     }
     $this->assertTrue($db->tableExists('Widgets'));
     $bt = BlockType::getByHandle('file');
     $this->assertInstanceOf('\\Concrete\\Core\\Block\\BlockType\\BlockType', $bt);
     $this->assertEquals(2, $bt->getBlockTypeID());
     // because we cleared it out once already.
     $ids = $db->GetOne('select count(btID) from BlockTypes');
     $this->assertEquals(1, $ids);
 }
Beispiel #4
0
 /**
  * Upgrade the current core version to the latest locally available by running the applicable migrations.
  */
 public static function updateToCurrentVersion()
 {
     $cms = Core::make('app');
     $cms->clearCaches();
     $em = ORM::entityManager('core');
     $dbm = Core::make('database/structure', array($em));
     $dbm->destroyProxyClasses('ConcreteCore');
     $dbm->generateProxyClasses();
     $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
     $configuration->registerPreviousMigratedVersions();
     $migrations = $configuration->getMigrationsToExecute('up', $configuration->getLatestVersion());
     foreach ($migrations as $migration) {
         $migration->execute('up');
     }
     Config::save('concrete.version_installed', Config::get('concrete.version'));
 }
Beispiel #5
0
 /**
  * Upgrade the current core version to the latest locally available by running the applicable migrations.
  */
 public static function updateToCurrentVersion()
 {
     $cms = Core::make('app');
     $cms->clearCaches();
     $em = ORM::entityManager();
     $dbm = new DatabaseStructureManager($em);
     $dbm->destroyProxyClasses('ConcreteCore');
     $dbm->generateProxyClasses();
     $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
     $configuration->registerPreviousMigratedVersions();
     $migrations = $configuration->getMigrationsToExecute('up', $configuration->getLatestVersion());
     foreach ($migrations as $migration) {
         $migration->execute('up');
     }
     try {
         $cms->make('helper/file')->makeExecutable(DIR_BASE_CORE . '/bin/concrete5', 'all');
     } catch (\Exception $x) {
     }
     Config::save('concrete.version_installed', Config::get('concrete.version'));
     Config::save('concrete.version_db_installed', Config::get('concrete.version_db'));
 }