/**
  * Override parent method
  * @note: we're removing generating of doctrine proxy classes within the try {} method
  * below (see parent for whats removed); generation is done in the after_exec hook of
  * pagodabox install while directories are still writable
  */
 public function install_database()
 {
     // Already configured? Bail out...
     $db = Loader::db();
     if (count($db->GetCol("SHOW TABLES")) > 0) {
         fwrite(STDERR, "\nDatabase already installed; leaving existing installation untouched and moving on...\n\n");
         exit(0);
     }
     try {
         Package::installDB(DIR_BASE_CORE . '/config/db.xml');
         $this->indexAdditionalDatabaseFields();
         $configuration = new Configuration();
         $version = $configuration->getVersion(Config::get('concrete.version_db'));
         $version->markMigrated();
     } catch (\Exception $e) {
         fwrite(STDERR, "\nUnable to install database: " . $db->ErrorMsg() . "\n\n");
         exit(0);
     }
 }
Exemplo n.º 2
0
 public function setupDoctrineCommands()
 {
     if (!Core::make('app')->isInstalled()) {
         return;
     }
     $helperSet = ConsoleRunner::createHelperSet(\ORM::entityManager());
     $this->setHelperSet($helperSet);
     $migrationsConfiguration = new MigrationsConfiguration();
     $output = new ConsoleOutput();
     $migrationsConfiguration->setOutputWriter(new OutputWriter(function ($message) use($output) {
         $output->writeln($message);
     }));
     /** @var \Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand[] $commands */
     $commands = array(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
     foreach ($commands as $migrationsCommand) {
         $migrationsCommand->setMigrationConfiguration($migrationsConfiguration);
         $this->add($migrationsCommand);
     }
     ConsoleRunner::addCommands($this);
 }
 public function install_database()
 {
     $db = Database::get();
     $num = $db->GetCol("show tables");
     if (count($num) > 0) {
         throw new \Exception(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num)));
     }
     $installDirectory = DIR_BASE_CORE . '/config';
     try {
         $em = \ORM::entityManager('core');
         $dbm = Core::make('database/structure', $em);
         $dbm->generateProxyClasses();
         Package::installDB($installDirectory . '/db.xml');
         $this->indexAdditionalDatabaseFields();
         $configuration = new Configuration();
         $version = $configuration->getVersion(Config::get('concrete.version_db'));
         $version->markMigrated();
     } catch (\Exception $e) {
         throw new \Exception(t('Unable to install database: %s', $db->ErrorMsg() ? $db->ErrorMsg() : $e->getMessage()));
     }
 }
Exemplo n.º 4
0
 /**
  * Upgrade the current core version to the latest locally available by running the applicable migrations.
  */
 public static function updateToCurrentVersion(Configuration $configuration = null)
 {
     $cms = Core::make('app');
     $cms->clearCaches();
     $em = ORM::entityManager();
     $dbm = new DatabaseStructureManager($em);
     $dbm->destroyProxyClasses('ConcreteCore');
     $dbm->generateProxyClasses();
     if (!$configuration) {
         $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'));
 }
 public function install_database()
 {
     $db = Database::get();
     $num = $db->GetCol("show tables");
     if (count($num) > 0) {
         throw new \Exception(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num)));
     }
     $installDirectory = DIR_BASE_CORE . '/config';
     try {
         // Retrieving metadata from the entityManager created with \ORM::entityManager()
         // will result in a empty metadata array. Because all drivers are wrapped in a driverChain
         // the method getAllMetadata() of Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory
         // is going to return a empty array. To overcome this issue a new EntityManager is create with the
         // only purpose to be used during the installation.
         $config = Setup::createConfiguration(true, \Config::get('database.proxy_classes'));
         \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('subpackages');
         \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');
         // Use default AnnotationReader
         $driverImpl = $config->newDefaultAnnotationDriver(DIR_BASE_CORE . DIRECTORY_SEPARATOR . DIRNAME_CLASSES . DIRECTORY_SEPARATOR . DIRNAME_ENTITIES, false);
         $config->setMetadataDriverImpl($driverImpl);
         $em = EntityManager::create(\Database::connection(), $config);
         $dbm = new DatabaseStructureManager($em);
         $dbm->destroyProxyClasses();
         $dbm->generateProxyClasses();
         Package::installDB($installDirectory . '/db.xml');
         $dbm->installDatabase();
         $this->indexAdditionalDatabaseFields();
         $configuration = new Configuration();
         $version = $configuration->getVersion(Config::get('concrete.version_db'));
         $version->markMigrated();
         $configuration->registerPreviousMigratedVersions();
     } catch (\Exception $e) {
         throw new \Exception(t('Unable to install database: %s', $db->ErrorMsg() ? $db->ErrorMsg() : $e->getMessage()));
     }
 }