Ejemplo n.º 1
0
 /**
  * Add the slug_column to the current table
  */
 public function modifyTable()
 {
     if (!$this->getTable()->containsColumn($this->getParameter('slug_column'))) {
         $this->getTable()->addColumn(array('name' => $this->getParameter('slug_column'), 'type' => 'VARCHAR', 'size' => 255));
         // add a unique to column
         $unique = new Unique($this->getColumnForParameter('slug_column'));
         $unique->setName($this->getTable()->getCommonName() . '_slug');
         $unique->addColumn($this->getTable()->getColumn($this->getParameter('slug_column')));
         $this->getTable()->addUnique($unique);
     }
 }
 /**
  * Add the slug_column to the current table
  */
 public function modifyTable()
 {
     $table = $this->getTable();
     $primary_string = $this->getParameter('primary_string');
     if (!$primary_string) {
         $this->exceptionError('Need set parameter "primary_string" in table ' . $table->getName());
     }
     if (!$table->hasColumn($primary_string)) {
         $this->exceptionError('Not found column "' . $primary_string . '" in table ' . $table->getName());
     }
     if (!$this->getTable()->containsColumn($this->getParameter('slug_column'))) {
         $this->getTable()->addColumn(array('name' => $this->getParameter('slug_column'), 'type' => 'VARCHAR', 'size' => 255));
         // add a unique to column
         $unique = new \Unique($this->getColumnForParameter('slug_column'));
         $unique->setName($this->getTable()->getCommonName() . '_slug');
         $unique->addColumn($this->getTable()->getColumn($this->getParameter('slug_column')));
         if ($this->getParameter('scope_column')) {
             $unique->addColumn($this->getTable()->getColumn($this->getParameter('scope_column')));
         }
         $this->getTable()->addUnique($unique);
     }
 }