Ejemplo n.º 1
0
 /**
  * Manage database schema
  */
 public function schemaManagerAction()
 {
     $request = $this->getRequest();
     // Set up logger. Log level is already validated by route.
     $priority = \Zend\Filter\StaticFilter::execute($request->getParam('loglevel', 'info'), 'Library\\LogLevel');
     $writer = new \Zend\Log\Writer\Stream('php://stderr');
     $writer->addFilter('priority', array('priority' => $priority));
     $writer->setFormatter('simple', array('format' => '%priorityName%: %message%'));
     $this->_logger->addWriter($writer);
     $this->_schemaManager->updateAll($request->getParam('prune'));
 }
Ejemplo n.º 2
0
 /**
  * Create or update table according to schema file
  *
  * The schema file is located in ./data/ClassName.json and contains all
  * information required to create or alter the table.
  *
  * @param bool $prune Drop obsolete columns
  * @codeCoverageIgnore
  */
 public function setSchema($prune = false)
 {
     $logger = $this->_serviceLocator->get('Library\\Logger');
     $schema = \Zend\Config\Factory::fromFile(Module::getPath('data/Tables/' . $this->_getClassName() . '.json'));
     $database = $this->_serviceLocator->get('Database\\Nada');
     $this->_preSetSchema($logger, $schema, $database, $prune);
     \Database\SchemaManager::setSchema($logger, $schema, $database, static::getObsoleteColumns($logger, $schema, $database), $prune);
     $this->_postSetSchema($logger, $schema, $database, $prune);
 }