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

20180117_81914.jpg
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容