Magento 2 available install schema columns type
Today we talk about Magento 2 available install schema columns type That we can use in install schema that is already mention in my post Magento 2 Create a install Schema. There are different type available in magneto 2. Type of column that you can is listed below with example.
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
'post_id',
Table::TYPE_BOOLEAN,
null,
[ 'identity' => false, 'nullable' => false, 'primary' => true ],
'Post ID'
)
Type smallint
TYPE_SMALLINT = ‘smallint’;
Example
'post_id',
Table::TYPE_SMALLINT,
null,
[ 'nullable' => false],
'Post ID'
)
Type integer
TYPE_INTEGER = ‘integer’;
Example
'post_id',
Table::TYPE_INTEGER,
null,
['nullable' => false],
'Post ID'
)
Type bigint
TYPE_BIGINT = ‘bigint’;
Example
'post_id',
Table::TYPE_BIGINT,
null,
[ 'nullable' => false],
'Post ID'
)
Type float
TYPE_FLOAT = ‘float’;
Example
'post_id',
Table::TYPE_FLOAT,
null,
[ 'nullable' => false],
'Post ID'
)
Type numeric
TYPE_NUMERIC = ‘numeric’;
Example
'post_id',
Table::TYPE_NUMERIC,
null,
[ 'nullable' => false],
'Post ID'
)
Type decimal
TYPE_DECIMAL = ‘decimal’;
Example
'post_id',
Table::TYPE_DECIMAL,
null,
[ 'nullable' => false],
'Post ID'
)
Type date
TYPE_DATE = ‘date’;
Example
'data',
Table::TYPE_DATE,
null,
[ 'nullable' => false],
'Post ID'
)
Type timestamp
TYPE_TIMESTAMP = ‘timestamp’;
Example
'creation_time',
Table::TYPE_TIMESTAMP,
null,
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
'Creation Time'
)
Type datetime
Capable to support date-time from 1970 + auto-triggers in some RDBMS
TYPE_DATETIME = ‘datetime’;
Example
'data',
Table::TYPE_DATETIME,
null,
[ 'nullable' => false ],
'Post ID'
)
Type text
Capable to support long date-time before 1970
TYPE_TEXT = ‘text’;
Example
'data',
Table::TYPE_TEXT,
255,
[ 'nullable' => false],
'Post ID'
)
Type blob
TYPE_BLOB = ‘blob’;
Example
'data',
Table::TYPE_BLOB ,
null,
[ 'nullable' => false],
'Post ID'
)
Type varbinary
Used for back compatibility, when query param can’t use statement options
TYPE_VARBINARY = ‘varbinary’;
Example
'data',
Table::TYPE_VARBINARY,
null,
[ 'nullable' => false],
'Post ID'
)
One thought on “Magento 2 available install schema columns type”
Leave a Reply
You must be logged in to post a comment.
Great article. It helps me a lot.