예제 #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;
 }
예제 #2
0
 /**
  * Create materialized view
  *
  * @return Mage_Mview_Model_Command_Create|mixed
  * @throws Exception
  * @throws Exception
  */
 public function execute()
 {
     if ($this->_table->isExists() || $this->_view->isExists()) {
         throw new Exception('Table or view with same name already exists!!!');
     }
     try {
         $this->_view->createFromSource($this->_select);
         $this->_table->createFromSource($this->_view->getName());
     } catch (Exception $e) {
         $this->_table->drop();
         $this->_view->drop();
         throw $e;
     }
     return $this;
 }
예제 #3
0
 /**
  * Drop materialized view table, view and metadata.
  *
  * @return Enterprise_Mview_Model_Action_Mview_Drop
  */
 public function execute()
 {
     $this->_view->drop();
     $this->_table->drop();
     $this->_metadata->delete();
     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()]);
 }
 /**
  * Create view and mview table
  * 1) Create view;
  * 2) Create table;
  * 3) Update view name and status in metadata.
  *
  * @return Enterprise_Mview_Model_Action_Mview_Create
  * @throws Exception
  */
 public function execute()
 {
     try {
         if (!$this->_view->isExists()) {
             $this->_view->createFromSource($this->_select);
         }
         if (!$this->_table->isExists()) {
             $select = $this->_connection->select()->from($this->_view->getObjectName());
             $this->_table->createFromSource($select);
         }
         $this->_metadata->setViewName($this->_view->getObjectName());
         $this->_metadata->setValidStatus();
         $this->_metadata->save();
     } catch (Exception $e) {
         $this->_view->drop();
         $this->_table->drop();
         throw $e;
     }
     return $this;
 }
예제 #6
0
 /**
  * Drops changelog table
  * Updates changelog_name in the metadata.
  *
  * @return Enterprise_Mview_Model_Action_Changelog_Create
  */
 public function execute()
 {
     $this->_changelog->drop();
     $this->_metadata->setData('changelog_name', null)->save();
     return $this;
 }