public function run()
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     $classes = PartKeepr::getClassMetaData();
     $tool->updateSchema($classes, true);
     $this->logMessage("Database Schema created/updated");
 }
Exemple #2
0
 public function updateSchema($em)
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $classes = array($em->getClassMetadata("Entities:User"), $em->getClassMetadata("Entities:Partener"), $em->getClassMetadata("Entities:Transaction"), $em->getClassMetadata("Entities:UserNotification"), $em->getClassMetadata("Entities:JobLog"), $em->getClassMetadata("Entities:Email"), $em->getClassMetadata("Entities:Task"), $em->getClassMetadata("Entities:TaskNotes"), $em->getClassMetadata("Entities:TaskList"), $em->getClassMetadata("Entities:TaskReminder"), $em->getClassMetadata("Entities:Rol"), $em->getClassMetadata("Entities:Permisiune"), $em->getClassMetadata("Entities:RolPermisiune"), $em->getClassMetadata("Entities:Pachet"), $em->getClassMetadata("Entities:Serviciu"), $em->getClassMetadata("Entities:CISession"), $em->getClassMetadata("Entities:Order"), $em->getClassMetadata("Entities:OrderItem"), $em->getClassMetadata("Entities:SimplePage"), $em->getClassMetadata("Entities:News"), $em->getClassMetadata("Entities:NewsletterSubscriber"));
     $tool->updateSchema($classes);
     exit("done");
 }
Exemple #3
0
 /**
  * @param \Venne\Module\IModule $module
  */
 public function install(IModule $module)
 {
     if (!$this->context->hasService('doctrine') || !$this->context->doctrine->createCheckConnection()) {
         throw new \Exception('Database connection not found!');
     }
     $classes = $this->getClasses($module);
     $metadata = array();
     foreach ($classes as $class) {
         $metadata[] = $this->entityManager->getClassMetadata($class);
     }
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     $this->entityManager->getConnection()->beginTransaction();
     try {
         foreach ($this->getAllClasses() as $class) {
             $metadata[] = $this->entityManager->getClassMetadata($class);
         }
         $tool->updateSchema($metadata);
         $this->entityManager->getConnection()->commit();
     } catch (Exception $e) {
         $this->entityManager->getConnection()->rollback();
         $this->entityManager->close();
         throw $e;
     }
     $this->cleanCache();
 }
 public function update(GenericEvent $event)
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($this->getClasses(), true);
     // Generate proxies for entities
     $this->em->getProxyFactory()->generateProxyClasses($this->getClasses(), __DIR__ . '/../../../../library/Proxy');
 }
 public static function UpdateSchema()
 {
     $metadata = self::$entityManager->getMetadataFactory()->getAllMetadata();
     $schemaTool = new Doctrine\ORM\Tools\SchemaTool(self::$entityManager);
     $schemaTool->updateSchema($metadata, true);
     return;
 }
Exemple #6
0
 /**
  * @todo
  */
 public function dbUpdate()
 {
     $success = true;
     try {
         $dummy = DB::em()->getConfiguration()->getMetadataDriverImpl();
         $dummy->addPaths(array(APPLICATION_PATH . '/models'));
         $metadatas = DB::em()->getMetadataFactory()->getAllMetadata();
         if (!empty($metadatas)) {
             $schemaTool = new \Doctrine\ORM\Tools\SchemaTool(DB::em());
             $sqls = $schemaTool->getUpdateSchemaSql($metadatas, true);
             if (!empty($sqls)) {
                 if (App::$inst->request->post('update')) {
                     $schemaTool->updateSchema($metadatas, true);
                     $message = 'Database schema updated successfully!';
                 } else {
                     $message = 'List of updates:<br/>';
                     $message .= implode(';' . PHP_EOL, $sqls) . ';';
                 }
             } else {
                 $message = 'SQLs are empty. Database schema is up to date';
             }
         } else {
             $message = 'Database schema is up to date';
         }
     } catch (Exception $e) {
         $success = false;
         $message = $e->getMessage() . $e->getTraceAsString();
     }
     $this->jsonResponse($success, $message);
 }
 public function update(GenericEvent $event)
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($this->getClasses(), true);
     $this->dispatcher->dispatch('newscoop_paywall.adapters.register', new AdaptersEvent($this, array()));
     // Generate proxies for entities
     $this->em->getProxyFactory()->generateProxyClasses($this->getClasses(), __DIR__ . '/../../../../library/Proxy');
 }
 public function update(GenericEvent $event)
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($this->getClasses(), true);
     $this->em->getProxyFactory()->generateProxyClasses($this->getClasses(), __DIR__ . '/../../../../library/Proxy');
     $this->setPermissions();
     $this->addJobs();
 }
Exemple #9
0
 public static function createStructureDatabase()
 {
     print_r("Criando a estrutura de dados de acordo com as entidades mapeadas.\n");
     $entityManager = self::getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $classes = $entityManager->getMetadataFactory()->getAllMetadata();
     $schemaTool->updateSchema($classes);
     print_r("Iniciando os testes unitários.\n\n");
 }
 public function update(GenericEvent $event)
 {
     if ($event->getArgument('plugin_name') != 'newscoop/meteoblue-plugin-bundle') {
         return;
     }
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($this->getClasses(), true);
     // Generate proxies for entities
     $this->em->getProxyFactory()->generateProxyClasses($this->getClasses(), __DIR__ . '/../../../../library/Proxy');
 }
Exemple #11
0
 public function execute()
 {
     if (envIsNot('development') || !ENV_DOCTRINE_ENABLED) {
         die('NOK');
     }
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     $classes = $this->entityManager->getMetadataFactory()->getAllMetadata();
     $schemaTool->updateSchema($classes);
     die('OK');
 }
 public function update()
 {
     $driver = $this->em->getConfiguration()->getMetadataDriverImpl();
     $entities_names = $driver->getAllClassNames();
     $entities_metadata = array();
     foreach ($entities_names as $name) {
         array_push($entities_metadata, $this->em->getClassMetadata($name));
     }
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($entities_metadata);
 }
 /**
  * Build the SQLite database before the tests suite.
  */
 public static function setUpBeforeClass()
 {
     self::$dbFile = sys_get_temp_dir() . '/fos-message/doctrine-orm.db';
     if (file_exists(self::$dbFile)) {
         unlink(self::$dbFile);
     } elseif (!file_exists(dirname(self::$dbFile))) {
         mkdir(dirname(self::$dbFile), 0777, true);
     }
     $em = self::createEntityManager();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->updateSchema([$em->getClassMetadata('FOS\\Message\\Driver\\Doctrine\\ORM\\Entity\\Conversation'), $em->getClassMetadata('FOS\\Message\\Driver\\Doctrine\\ORM\\Entity\\ConversationPerson'), $em->getClassMetadata('FOS\\Message\\Driver\\Doctrine\\ORM\\Entity\\Message'), $em->getClassMetadata('FOS\\Message\\Driver\\Doctrine\\ORM\\Entity\\MessagePerson'), $em->getClassMetadata('FOS\\Message\\Driver\\Doctrine\\ORM\\Entity\\Tag'), $em->getClassMetadata('FOS\\Message\\Tests\\Driver\\Doctrine\\ORM\\Entity\\TestPerson')]);
 }
 public function update(GenericEvent $event)
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($this->getClasses(), true);
     // Generate proxies for entities
     $this->em->getProxyFactory()->generateProxyClasses($this->getClasses(), __DIR__ . '/../../../../library/Proxy');
     // Update articletype
     $this->articleTypeConfigurationService->update();
     // Register parsers
     $this->dispatcher->dispatch('newscoop_ingest.parser.register', new IngestParsersEvent($this, array()));
     // Only add if the job doesn't exist
     $this->updateJobs();
     // Set persissions
     $this->setPermissions();
 }
Exemple #15
0
 public function setUp()
 {
     self::$config = (include __DIR__ . '/../../../config.php');
     $dsn = new Dsn(self::$config['db_adapter']['connection']['dsn']);
     $dsn = $dsn->parse();
     $pdo = new \PDO(self::$config['db_adapter']['connection']['dsn'], $dsn['username'], $dsn['password']);
     $pdo->beginTransaction();
     $pdo->exec('CREATE DATABASE ' . $dsn['database']);
     // or die(print_r($pdo->errorInfo()));
     $pdo->commit();
     self::$em = new EntityManager(empty(self::$config['db_adapter']['connection']['dsn']) ? self::$config['db_adapter']['connection'] : self::$config['db_adapter']['connection']['dsn'], empty(self::$config['db_adapter']['options']['doctrine']) ? array() : self::$config['db_adapter']['options']['doctrine']);
     $tool = new \Doctrine\ORM\Tools\SchemaTool(self::$em);
     $classes = $this->db(self::$config['db_adapter']['options']['doctrine']['modelsPath']);
     //        foreach ($classes as $class) echo $class->name . "\n";
     //        die(print_r($tool->getUpdateSchemaSql($classes)));
     $tool->updateSchema($classes);
 }
 /**
  * Updates the DB schema using Doctrine's SchemaTool. The $safeMode flag is passed
  * to SchemaTool unchanged.
  *
  * @param boolean $safeMode
  * @param string $outputPathAndFilename A file to write SQL to, instead of executing it
  * @return string
  */
 public function updateSchema($safeMode = true, $outputPathAndFilename = null)
 {
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     if ($outputPathAndFilename === null) {
         $schemaTool->updateSchema($this->entityManager->getMetadataFactory()->getAllMetadata(), $safeMode);
     } else {
         file_put_contents($outputPathAndFilename, implode(PHP_EOL, $schemaTool->getUpdateSchemaSql($this->entityManager->getMetadataFactory()->getAllMetadata(), $safeMode)));
     }
 }
Exemple #17
0
 public function databaseSetupAction()
 {
     $view = new ViewModel();
     $view->setTemplate('reliv/index/database');
     /** @var \Doctrine\ORM\EntityManager $em */
     $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $repo = $em->getRepository('\\Rcm\\Entity\\Country');
     try {
         $country = $repo->findOneBy(array('iso3' => 'USA'));
     } catch (TableNotFoundException $e) {
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
         $classes = $em->getMetadataFactory()->getAllMetadata();
         try {
             $schemaTool->createSchema($classes);
         } catch (ToolsException $e) {
             try {
                 $schemaTool->updateSchema($classes);
             } catch (ToolsException $e) {
                 $view->setVariable('error', array('message' => $e->getMessage()));
                 return $view;
             }
         }
         $config = $this->getConfig();
         if (is_array($config['fixtures'])) {
             $this->addFixtures($config['fixtures']);
         }
     }
     return $this->redirect()->toRoute('Rcm\\RcmInstall/default', array("action" => "content"));
 }
Exemple #18
0
require 'bootstrap.php';
$app = new App\Application();
//Index
$app->get('/', function () use($app) {
    $action = $app->getAction('Index');
    return $action->run();
});
$app->get('/authenticate-twitter', function () use($app) {
    $action = $app->getAction('AuthenticateTwitter');
    return $action->run();
});
$app->get('/authorize-twitter', function () use($app) {
    $action = $app->getAction('AuthorizeTwitter');
    return $action->run();
});
$app->get('/process', function () use($app) {
    $action = $app->getAction('Process');
    return $action->run();
});
$app->get('/result', function () use($app) {
    $action = $app->getAction('Result');
    return $action->run();
});
$app->get('/updateschema', function () use($app) {
    $em = $app->getDoctrineEntityManager();
    $metadatas = $em->getMetadataFactory()->getAllMetadata();
    $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
    $tool->updateSchema($metadatas, true);
});
return $app;
Exemple #19
0
 public function dropSchema(EntityManager $entityManager)
 {
     $classes = $entityManager->getMetadataFactory()->getAllMetadata();
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $schemaTool->updateSchema(array());
 }
 public function createDatabase()
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $classes = array($this->getClassMetadata('Host'), $this->getClassMetadata('Tournament'), $this->getClassMetadata('Category'), $this->getClassMetadata('Group'), $this->getClassMetadata('Match'), $this->getClassMetadata('Team'), $this->getClassMetadata('Club'), $this->getClassMetadata('Site'), $this->getClassMetadata('Playground'), $this->getClassMetadata('PlaygroundAttribute'), $this->getClassMetadata('Timeslot'), $this->getClassMetadata('GroupOrder'), $this->getClassMetadata('Enrollment'), $this->getClassMetadata('MatchRelation'), $this->getClassMetadata('QMatchRelation'), $this->getClassMetadata('Event'), $this->getClassMetadata('News'), $this->getClassMetadata('User'), $this->getClassMetadata('Champion'), $this->getClassMetadata('HostPlan'), $this->getClassMetadata('MatchAlternative'), $this->getClassMetadata('MatchSchedule'), $this->getClassMetadata('QMatchSchedule'), $this->getClassMetadata('MatchSchedulePlan'), $this->getClassMetadata('MatchScheduleRelation'), $this->getClassMetadata('QMatchScheduleRelation'), $this->getClassMetadata('SocialGroup'), $this->getClassMetadata('SocialRelation'), $this->getClassMetadata('TournamentOption'), $this->getClassMetadata('Template'));
     $tool->updateSchema($classes);
 }
Exemple #21
0
 public function updateSchema()
 {
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $classes = $this->em->getMetadataFactory()->getAllMetadata();
     $sql = $schemaTool->getUpdateSchemaSql($classes);
     $schemaTool->updateSchema($classes, true);
     return $sql;
 }
Exemple #22
0
 public function updateSchema()
 {
     $em = $this->em;
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $classes = $this->_getShemaClasses();
     $tool->updateSchema($classes, true);
     return $this;
 }
Exemple #23
0
<?php

require 'vendor/autoload.php';
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/views'));
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new Silex\Provider\DoctrineServiceProvider(), array('db.options' => array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/app.db')));
$app->register(new Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array('orm.proxies_dir' => __DIR__ . '/proxies', 'orm.em.options' => array('mappings' => [['type' => 'annotation', 'namespace' => 'Entities', 'path' => __DIR__ . '/entities']])));
// TODO! mod uploading / downloading
// TODO make things not look like shit
$tool = new \Doctrine\ORM\Tools\SchemaTool($app['orm.em']);
$classes = array($app['orm.em']->getClassMetadata('Entities\\User'), $app['orm.em']->getClassMetadata('Entities\\Keys'), $app['orm.em']->getClassMetadata('Entities\\Mods'));
$tool->updateSchema($classes);
function validate_key($key)
{
    global $app;
    // evil!
    $query = $app['orm.em']->createQuery('SELECT k from Entities\\Keys k WHERE k.key = :key AND k.valid = true');
    $query->setParameter('key', $key);
    $values = $query->getResult();
    return count($values) > 0;
}
$root = $app['controllers_factory'];
$admin = $app['controllers_factory'];
$root->get('/', function () use($app) {
    return $app['twig']->render('index.twig');
});
$admin->get('/', function () use($app) {
    return $app['twig']->render('indwtex.twig');
});
 /**
  * Called from functional tests, creates/updates database tables and compiles proxies.
  *
  * @return boolean
  */
 public function compile()
 {
     // "driver" is used only for Doctrine, thus we (mis-)use it here
     // additionally, when no path is set, skip this step, assuming no DB is needed
     if ($this->settings['backendOptions']['driver'] !== null && $this->settings['backendOptions']['path'] !== null) {
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
         if ($this->settings['backendOptions']['driver'] === 'pdo_sqlite') {
             $schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
         } else {
             $schemaTool->updateSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
         }
         $proxyFactory = $this->entityManager->getProxyFactory();
         $proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
         $this->systemLogger->log('Doctrine 2 setup finished');
         return true;
     } else {
         $this->systemLogger->log('Doctrine 2 setup skipped, driver and path backend options not set!', LOG_NOTICE);
         return false;
     }
 }
Exemple #25
0
 /**
  * 
  * Importa los datos previamente salvados con el Exporter hacia la base de datos
  * Esta funcion retorna TRUE si la rutina fue realizada con exito, FALSE en caso contrario
  * 
  * $this->getStore()->getImporter()->createIfNotExist(true)->import(__DIR__.'/exportExample.php');
  * 
  * @param string $file el archivo a subir
  * @throws \Exception throws una excepcion cuando el archivo a subir no exista
  * @return boolean
  */
 public function import($file)
 {
     if (!file_exists($file)) {
         throw new \Exception("The file especified in the Importer does not exist");
     }
     include $file;
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->store->getManager());
     try {
         $meta = array();
         if ($this->create) {
             foreach ($create as $class) {
                 $meta[] = $this->store->getManager()->getMetadataFactory()->getMetadataFor($class);
             }
             //$schemaTool->createSchema($meta);
             $schemaTool->updateSchema($meta, true);
         }
     } catch (\Exception $exc) {
     }
     try {
         $this->store->getManager()->getConnection()->beginTransaction();
         $ord = new TableDependencyOrder(array_keys($data), $this->store);
         $dependency = $ord->getOrder();
         foreach ($dependency as $tableName) {
             $rows = $data[$tableName];
             //                if($clearTable)
             //                    $this->store->getManager()->getConnection()->executeQuery("DELETE FROM $tableName");
             foreach ($rows as $row) {
                 $this->store->getManager()->getConnection()->insert($tableName, $row);
             }
         }
         $this->store->getManager()->getConnection()->commit();
         return true;
     } catch (\Exception $exc) {
         $this->errors = $exc->getMessage();
         $this->store->getManager()->getConnection()->rollback();
         return false;
     }
 }
Exemple #26
0
 public function processValues()
 {
     /**
      * 2) Create database.
      *
      * Has the user requested to create the database?
      */
     if (isset($_POST['config']['database']['create_database']) and $_POST['config']['database']['create_database'] == 'on') {
         try {
             // connection without dbname (must be blank for create table)
             $connectionParams = array('user' => $_POST['config']['database']['user'], 'password' => $_POST['config']['database']['password'], 'host' => $_POST['config']['database']['host'], 'driver' => $_POST['config']['database']['driver']);
             $config = new \Doctrine\DBAL\Configuration();
             $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
             $connection->setCharset('UTF8');
             /**
              * fetch doctrine schema manager
              * and create database
              */
             $schema_manager = $connection->getSchemaManager();
             $schema_manager->createDatabase($_POST['config']['database']['dbname']);
             /**
              * Another way of doing this is via the specific database platform command.
              * Then for creating the database the platform is asked, which SQL CMD to use.
              * For "pdo_mysql" it would result in a string like 'CREATE DATABASE name'.
              */
             #$db = $connection->getDatabasePlatform();
             #$sql = $db->getCreateDatabaseSQL('databasename');
             #$connection->exec($sql);
             // Drop Connection.
             unset($connection);
         } catch (\Exception $e) {
             // force return
             $this->setStep(4);
             $error = $this->language['ERROR_WHILE_CREATING_DATABASE'] . NL . NL;
             $error .= $e->getMessage() . '.';
             $this->setErrorMessage($error);
         }
     }
     /**
      * 3) Connect to Database
      */
     // Setup Connection Parameters. This time with "dbname".
     $connectionParams = array('dbname' => $_POST['config']['database']['dbname'], 'user' => $_POST['config']['database']['user'], 'password' => $_POST['config']['database']['password'], 'host' => $_POST['config']['database']['host'], 'driver' => $_POST['config']['database']['driver'], 'prefix' => $_POST['config']['database']['prefix']);
     $entityManager = Helper::getDoctrineEntityManager($connectionParams);
     /**
      * 4) Validate Database Schemas
      */
     try {
         // instantiate validator
         $validator = new \Doctrine\ORM\Tools\SchemaValidator($entityManager);
         // validate
         $validation_error = $validator->validateMapping();
         // handle validation errors
         if ($validation_error) {
             // @todo this is experimental...
             $this->setErrorMessage(var_export($validation_error, false));
         }
     } catch (Exception $e) {
         // force return
         $this->setStep(4);
         $error = $this->language['ERROR_NO_DB_CONNECT'] . NL . $e->getMessage();
         $this->setErrorMessage($error);
     }
     /**
      * 5) Insert/Update Schemas
      *
      * "recreate" will do a database drop, before schemas are updated.
      */
     try {
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
         $metadata = $entityManager->getMetadataFactory()->getAllMetadata();
         if (isset($_GET['recreate'])) {
             $schemaTool->dropSchema($metadata);
         }
         $schemaTool->updateSchema($metadata);
         $entityManager->flush();
     } catch (Exception $e) {
         $html = '';
         $html .= 'The update failed!' . NL;
         $html .= 'Do you want to force a database drop (' . $connectionParams['dbname'] . ')?' . NL;
         $html .= 'This will result in a total loss of all data and database tables.' . NL;
         $html .= 'It will allow for an clean installation of the database.' . NL;
         $html .= 'WARNING: Act carefully!' . NL;
         $html .= '<form action="index.php?step=4&recreate=true" method="post">';
         $html .= '<input type="submit" value="Recreate Database" class="retry"></form>';
         // force return
         $this->setStep(4);
         $error = $this->language['ERROR_NO_DB_CONNECT'] . NL . $e->getMessage();
         $error .= NL . NL . $html;
         $this->setErrorMessage($error);
     }
     /**
      * 6. Write Settings to clansuite.config.php
      */
     if (false === Helper::write_config_settings($_POST['config'])) {
         // force return
         $this->setStep(4);
         $error = 'Config not written.' . NL;
         $this->setErrorMessage($error);
     }
 }
Exemple #27
0
 public function updateSchema(&$em = null, $entitiesClasses = null)
 {
     if ($entitiesClasses === null) {
         $entitiesClasses = $this->getEntities();
     }
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     foreach ($entitiesClasses as $entity) {
         $classes[] = $em->getClassMetadata($entity);
     }
     $tool->updateSchema($classes);
     $this->generateUpdateEntity($em, $classes);
 }
 public static function register($panel, $group = 'Doctrine')
 {
     $panel->addCommand($group, Command::create('Create Schema', function ($container) {
         $em = $container->entityManager;
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
         $metadatas = $em->getMetadataFactory()->getAllMetadata();
         $schemaTool->createSchema($metadatas);
     }));
     $panel->addCommand($group, Command::create('Update Schema', function ($container) {
         $em = $container->entityManager;
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
         $metadatas = $em->getMetadataFactory()->getAllMetadata();
         $schemaTool->updateSchema($metadatas);
     }));
     $panel->addCommand($group, Command::create('Drop Schema', function ($container) {
         $em = $container->entityManager;
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
         $metadatas = $em->getMetadataFactory()->getAllMetadata();
         $schemaTool->dropSchema($metadatas);
     }));
 }
Exemple #29
0
 public function database()
 {
     $em = $this->app->entityManager();
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $schemaTool->updateSchema($em->getMetadataFactory()->getAllMetadata());
 }
Exemple #30
0
<?php

define('APPLICATION_ENV', 'development');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../'));
echo APPLICATION_PATH;
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->getBootstrap()->bootstrap('doctrine');
$em = $application->getBootstrap()->getResource('doctrine');
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
$metadata = $em->getMetadataFactory()->getAllMetadata();
$schemaTool->updateSchema($metadata);