Magento 2 available install schema columns type

Magento 2 available install schema columns type

1. Type boolean

TYPE_BOOLEAN = ‘boolean’;

Boolean: These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true.
Example

addColumn(
            'post_id',
            Table::TYPE_BOOLEAN,
            null,
            [ 'identity' => false, 'nullable' => false, 'primary' => true ],
            'Post ID'
        )

2. Type smallint

TYPE_SMALLINT = ‘smallint’;

Example

addColumn(
            'post_id',
            Table::TYPE_SMALLINT,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

3. Type integer

TYPE_INTEGER = ‘integer’;

Example

addColumn(
            'post_id',
            Table::TYPE_INTEGER,
            null,
            ['nullable' => false],
            'Post ID'
        )

4. Type bigint

TYPE_BIGINT = ‘bigint’;

Example

addColumn(
            'post_id',
            Table::TYPE_BIGINT,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

5. Type float

TYPE_FLOAT = ‘float’;

Example

addColumn(
            'post_id',
            Table::TYPE_FLOAT,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

6. Type numeric

TYPE_NUMERIC = ‘numeric’;

Example

addColumn(
            'post_id',
            Table::TYPE_NUMERIC,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

7. Type decimal

TYPE_DECIMAL = ‘decimal’;

Example

addColumn(
            'post_id',
            Table::TYPE_DECIMAL,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

8. Type date

TYPE_DATE = ‘date’;

Example

addColumn(
            'data',
            Table::TYPE_DATE,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

9. Type timestamp

TYPE_TIMESTAMP = ‘timestamp’;

Example

->addColumn(
            'creation_time',
            Table::TYPE_TIMESTAMP,
            null,
            ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
            'Creation Time'
        )

10. Type datetime

Capable to support date-time from 1970 + auto-triggers in some RDBMS

TYPE_DATETIME = ‘datetime’;

Example

addColumn(
            'data',
            Table::TYPE_DATETIME,
            null,
            [ 'nullable' => false ],
            'Post ID'
        )

11. Type text

Capable to support long date-time before 1970

TYPE_TEXT = ‘text’;

Example

addColumn(
            'data',
            Table::TYPE_TEXT,
            255,
            [ 'nullable' => false],
            'Post ID'
        )

12. Type blob

TYPE_BLOB = ‘blob’;

Example

addColumn(
            'data',
            Table::TYPE_BLOB ,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

13. Type varbinary

Used for back compatibility, when query param can’t use statement options

TYPE_VARBINARY = ‘varbinary’;

Example

addColumn(
            'data',
            Table::TYPE_VARBINARY,
            null,
            [ 'nullable' => false],
            'Post ID'
        )

That's all.


More Information, Please Subscribe My Wechat Public Platform Or View My Blog : https://www.abmbio.xin

Magento 2 available install schema columns type_第1张图片
20180117_81914.jpg

你可能感兴趣的:(Magento 2 available install schema columns type)