Ejemplo n.º 1
0
 /**
  * Creates a table column.
  *
  * @param array $column column metadata
  *
  * @return ColumnSchema normalized column metadata
  */
 protected function createColumn($column)
 {
     $c = new ColumnSchema(['name' => $column['name']]);
     $c->rawName = $this->quoteColumnName($c->name);
     $c->allowNull = $column['is_nullable'] == '1';
     $c->isPrimaryKey = $column['is_primary_key'] == '1';
     $c->isUnique = $column['is_unique'] == '1';
     $c->isIndex = $column['constraint_name'] !== null;
     $c->dbType = $column['type'];
     if ($column['precision'] !== '0') {
         if ($column['scale'] !== '0') {
             // We have a numeric datatype
             $c->precision = (int) $column['precision'];
             $c->scale = (int) $column['scale'];
         } else {
             $c->size = (int) $column['precision'];
         }
     } else {
         $c->size = $column['max_length'] !== '-1' ? (int) $column['max_length'] : null;
     }
     $c->autoIncrement = $column['is_identity'] === '1';
     $c->comment = isset($column['Comment']) ? $column['Comment'] === null ? '' : $column['Comment'] : '';
     $c->extractFixedLength($column['type']);
     $c->extractMultiByteSupport($column['type']);
     $c->extractType($column['type']);
     if (isset($column['default_definition'])) {
         $c->extractDefault($column['default_definition']);
     }
     return $c;
 }