Ejemplo n.º 1
0
 /**
  * Builds the DDL SQL to modify a column
  *
  * @return     string
  */
 public function getModifyColumnDDL(PropelColumnDiff $columnDiff)
 {
     $toColumn = $columnDiff->getToColumn();
     $pattern = "\nALTER TABLE %s MODIFY %s;\n";
     return sprintf($pattern, $this->quoteIdentifier($toColumn->getTable()->getName()), $this->getColumnDDL($toColumn));
 }
Ejemplo n.º 2
0
 /**
  * Overrides the implementation from DefaultPlatform
  *
  * @author     Niklas Närhinen <*****@*****.**>
  * @return     string
  * @see        DefaultPlatform::getModifyColumnDDL
  */
 public function getModifyColumnDDL(PropelColumnDiff $columnDiff)
 {
     $ret = '';
     $changedProperties = $columnDiff->getChangedProperties();
     $toColumn = $columnDiff->getToColumn();
     $table = $toColumn->getTable();
     $colName = $this->quoteIdentifier($toColumn->getName());
     $pattern = "\nALTER TABLE %s ALTER COLUMN %s;\n";
     foreach ($changedProperties as $key => $property) {
         switch ($key) {
             case 'defaultValueType':
                 continue;
             case 'size':
             case 'type':
             case 'scale':
                 $sqlType = $toColumn->getDomain()->getSqlType();
                 if ($toColumn->isAutoIncrement() && $table && $table->getIdMethodParameters() == null) {
                     $sqlType = $toColumn->getType() === PropelTypes::BIGINT ? 'bigserial' : 'serial';
                 }
                 if ($this->hasSize($sqlType)) {
                     $sqlType .= $toColumn->getDomain()->printSize();
                 }
                 $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . ' TYPE ' . $sqlType);
                 break;
             case 'defaultValueValue':
                 if ($property[0] !== null && $property[1] === null) {
                     $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . ' DROP DEFAULT');
                 } else {
                     $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . ' SET ' . $this->getColumnDefaultValueDDL($toColumn));
                 }
                 break;
             case 'notNull':
                 $notNull = " DROP NOT NULL";
                 if ($property[1]) {
                     $notNull = " SET NOT NULL";
                 }
                 $ret .= sprintf($pattern, $this->quoteIdentifier($table->getName()), $colName . $notNull);
                 break;
         }
     }
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * Builds the DDL SQL to modify a column
  *
  * @return     string
  */
 public function getModifyColumnDDL(PropelColumnDiff $columnDiff)
 {
     return $this->getChangeColumnDDL($columnDiff->getFromColumn(), $columnDiff->getToColumn());
 }