예제 #1
0
 /**
  * Create materialized view
  *
  * @return Mage_Mview_Model_Command_Create|mixed
  * @throws Exception
  * @throws Exception
  */
 public function execute()
 {
     if (!$this->_mview->isExists() || $this->_changelog->isExists()) {
         throw new Exception('Mview does not exists or changelog with same name already exists!!!');
     }
     $describe = $this->_mview->describe();
     $column = $describe[$this->_ruleColumn];
     $table = $this->_connection->newTable()->addColumn($this->_ruleColumn, $column['DATA_TYPE'], implode(',', array($column['LENGTH'], $column['SCALE'], $column['PRECISION'])), array('unsigned' => $column['UNSIGNED'], 'nullable' => false, 'primary' => true), 'Id')->setComment(sprintf('Changelog for table `%s`', $this->_mview->getName()));
     $this->_changelog->create($table);
     return $this;
 }
 /**
  * Returns column definition for column provided in key_column parameter.
  *
  * @return array
  * @throws Enterprise_Mview_Exception
  */
 protected function _getKeyColumnConfig()
 {
     $describe = $this->_table->describe();
     if (!array_key_exists($this->_metadata->getKeyColumn(), $describe)) {
         throw new Enterprise_Mview_Exception(sprintf("Column '%s' does not exist in the '%s' table", $this->_metadata->getKeyColumn(), $this->_table->getObjectName()));
     }
     return $this->_connection->getColumnCreateByDescribe($describe[$this->_metadata->getKeyColumn()]);
 }