public function format()
 {
     $sql = [];
     $sql[] = $this->formatterProvider->delimite($this->columnFragment->getName());
     $schemaProperty = $this->columnFragment->getSchemaProperty();
     if (!isset(self::$typeList[$schemaProperty->getType()])) {
         throw new StorageException(sprintf('Unknown column fragment type [%s].', $schemaProperty->getType()));
     }
     $sql[] = self::$typeList[$schemaProperty->getType()];
     if ($schemaProperty->isPrimary()) {
         $sql[] = 'PRIMARY KEY';
     }
     if ($schemaProperty->isRequired()) {
         $sql[] = 'NOT NULL';
     }
     return $this->sql(implode(' ', $sql));
 }
Esempio n. 2
0
 /**
  * add given column to table definition; schema definition has priority
  *
  * @param ColumnFragment $columnFragment
  *
  * @return $this
  */
 public function addColumn(ColumnFragment $columnFragment)
 {
     $this->columnList[$columnFragment->getName()] = $columnFragment;
     return $this;
 }