src/Builder/TypeTableBuilder.php
private function prepareTypeDefinition(ScalarField $field)
    {
        if ($field instanceof IntegerField) {
            switch ($field->getSize()) {
                case FieldInterface::SIZE_TINY:
                    $result = 'TINYINT';
                    break;
                case ScalarField::SIZE_SMALL:
                    $result = 'SMALLINT';
                    break;
                case FieldInterface::SIZE_MEDIUM:
                    $result = 'MEDIUMINT';
                    break;
                case FieldInterface::SIZE_BIG:
                    $result = 'BIGINT';
                    break;
                default:
                    $result = 'INT';
            }

            if ($field->isUnsigned()) {
                $result .= ' UNSIGNED';
            }

            if ($field->getName() == 'id') {
                $result .= ' AUTO_INCREMENT';
            }

            return $result;
        } elseif ($field instanceof BooleanField) {
            return 'TINYINT(1) UNSIGNED';
        } elseif ($field instanceof DateField) {
            return 'DATE';
        } elseif ($field instanceof DateTimeField) {
            return 'DATETIME';
        } elseif ($field instanceof DecimalField) {
            $result = 'DECIMAL(' . $field->getLength() . ', ' . $field->getScale() . ')';

            if ($field->isUnsigned()) {
                $result .= ' UNSIGNED';
            }

            return $result;
        } elseif ($field instanceof EnumField) {
            return 'ENUM(' . implode(',', array_map(function ($possibility) {
                return $this->getConnection()->escapeValue($possibility);
            }, $field->getPossibilities())) . ')';
        } elseif ($field instanceof FloatField) {
            $result = 'FLOAT(' . $field->getLength() . ', ' . $field->getScale() . ')';

            if ($field->isUnsigned()) {
                $result .= ' UNSIGNED';
            }

            return $result;
        } elseif ($field instanceof JsonField) {
            return 'JSON';
        } elseif ($field instanceof StringField) {
            return 'VARCHAR(' . $field->getLength() . ')';
        } elseif ($field instanceof TextField) {
            switch ($field->getSize()) {
                case FieldInterface::SIZE_TINY:
                    return 'TINYTEXT';
                case ScalarField::SIZE_SMALL:
                    return 'TEXT';
                case FieldInterface::SIZE_MEDIUM:
                    return 'MEDIUMTEXT';
                default:
                    return 'LONGTEXT';
            }
        } elseif ($field instanceof TimeField) {
            return 'TIME';
        } else {
            throw new InvalidArgumentException('Field ' . get_class($field) . ' is not a support scalar field');
        }
    }
private function prepareTypeDefinition(ScalarField $field)
    {
        if ($field instanceof IntegerField) {
            switch ($field->getSize()) {
                case FieldInterface::SIZE_TINY:
                    $result = 'TINYINT';
                    break;
                case ScalarField::SIZE_SMALL:
                    $result = 'SMALLINT';
                    break;
                case FieldInterface::SIZE_MEDIUM:
                    $result = 'MEDIUMINT';
                    break;
                case FieldInterface::SIZE_BIG:
                    $result = 'BIGINT';
                    break;
                default:
                    $result = 'INT';
            }

            if ($field->isUnsigned()) {
                $result .= ' UNSIGNED';
            }

            if ($field->getName() == 'id') {
                $result .= ' AUTO_INCREMENT';
            }

            return $result;
        } elseif ($field instanceof BooleanField) {
            return 'TINYINT(1) UNSIGNED';
        } elseif ($field instanceof DateField) {
            return 'DATE';
        } elseif ($field instanceof DateTimeField) {
            return 'DATETIME';
        } elseif ($field instanceof DecimalField) {
            $result = 'DECIMAL(' . $field->getLength() . ', ' . $field->getScale() . ')';

            if ($field->isUnsigned()) {
                $result .= ' UNSIGNED';
            }

            return $result;
        } elseif ($field instanceof EnumField) {
            return 'ENUM(' . implode(',', array_map(function ($possibility) {
                return $this->getConnection()->escapeValue($possibility);
            }, $field->getPossibilities())) . ')';
        } elseif ($field instanceof FloatField) {
            $result = 'FLOAT(' . $field->getLength() . ', ' . $field->getScale() . ')';

            if ($field->isUnsigned()) {
                $result .= ' UNSIGNED';
            }

            return $result;
        } elseif ($field instanceof JsonField) {
            return 'JSON';
        } elseif ($field instanceof StringField) {
            return 'VARCHAR(' . $field->getLength() . ')';
        } elseif ($field instanceof TextField) {
            switch ($field->getSize()) {
                case FieldInterface::SIZE_TINY:
                    return 'TINYTEXT';
                case ScalarField::SIZE_SMALL:
                    return 'TEXT';
                case FieldInterface::SIZE_MEDIUM:
                    return 'MEDIUMTEXT';
                default:
                    return 'LONGTEXT';
            }
        } elseif ($field instanceof TimeField) {
            return 'TIME';
        } else {
            throw new InvalidArgumentException('Field ' . get_class($field) . ' is not a support scalar field');
        }
    }
private function prepareTypeDefinition ( ScalarField $ field ) { if ( $ field instanceof IntegerField ) { switch ( $ field -> getSize ( ) ) { case FieldInterface :: SIZE_TINY : $ result = 'TINYINT' ; break ; case ScalarField :: SIZE_SMALL : $ result = 'SMALLINT' ; break ; case FieldInterface :: SIZE_MEDIUM : $ result = 'MEDIUMINT' ; break ; case FieldInterface :: SIZE_BIG : $ result = 'BIGINT' ; break ; default : $ result = 'INT' ; } if ( $ field -> isUnsigned ( ) ) { $ result .= ' UNSIGNED' ; } if ( $ field -> getName ( ) == 'id' ) { $ result .= ' AUTO_INCREMENT' ; } return $ result ; } elseif ( $ field instanceof BooleanField ) { return 'TINYINT(1) UNSIGNED' ; } elseif ( $ field instanceof DateField ) { return 'DATE' ; } elseif ( $ field instanceof DateTimeField ) { return 'DATETIME' ; } elseif ( $ field instanceof DecimalField ) { $ result = 'DECIMAL(' . $ field -> getLength ( ) . ', ' . $ field -> getScale ( ) . ')' ; if ( $ field -> isUnsigned ( ) ) { $ result .= ' UNSIGNED' ; } return $ result ; } elseif ( $ field instanceof EnumField ) { return 'ENUM(' . implode ( ',' , array_map ( function ( $ possibility ) { return $ this -> getConnection ( ) -> escapeValue ( $ possibility ) ; } , $ field -> getPossibilities ( ) ) ) . ')' ; } elseif ( $ field instanceof FloatField ) { $ result = 'FLOAT(' . $ field -> getLength ( ) . ', ' . $ field -> getScale ( ) . ')' ; if ( $ field -> isUnsigned ( ) ) { $ result .= ' UNSIGNED' ; } return $ result ; } elseif ( $ field instanceof JsonField ) { return 'JSON' ; } elseif ( $ field instanceof StringField ) { return 'VARCHAR(' . $ field -> getLength ( ) . ')' ; } elseif ( $ field instanceof TextField ) { switch ( $ field -> getSize ( ) ) { case FieldInterface :: SIZE_TINY : return 'TINYTEXT' ; case ScalarField :: SIZE_SMALL : return 'TEXT' ; case FieldInterface :: SIZE_MEDIUM : return 'MEDIUMTEXT' ; default : return 'LONGTEXT' ; } } elseif ( $ field instanceof TimeField ) { return 'TIME' ; } else { throw new InvalidArgumentException ( 'Field ' . get_class ( $ field ) . ' is not a support scalar field' ) ; } }
Prepare type definition for the given field.

@param  ScalarField $field
@return string
Prepare type definition for the given field .