Why is not supported in the Migration tinyint
$this->createTable('{{%my_table}}', [
'id' => $this->primaryKey(),
'other' => 'tinyint not null',
]);
@mdmunir I think to do
$this->createTable('{{%my_table}}', [
'id' => $this->primaryKey(),
'other' => $this->tinyint()->notNull(),
]);
This data type exists in MySQL only, therefore we did not create a shortcut for it.
@SilverFire then what about creating a generic method, where we can tell the type and length?
$this->createTable('{{%my_table}}', [
'id' => $this->primaryKey(),
'other' => $this->nameForGenericColumnCreator('tinyint', 3)->notNull()->defaultValue(0)->after('field'),
]);
It's bad not to have a specific type because when we make a schema synchronization always accuses fails because the tinyint field.
Simply ignore their existence should not be the best option.
I believe that other DBMS must have the same problem of specific types and would be resolved with this general solution.
Cheers!!
@thiagotalma
'other' => (new yii\db\ColumnSchemaBuilder('random', 3, $this->db))->otherMethods(),
tinyint() is useful when i use mysql。 i write code
like 'tinyint not null' ,then if i want use it for other database,i shoud write like this everywhere
$this->db->driverName === 'mysql'?'tinyint not null' :$this->smallInt()->notNull()
$this->tinyInteger(1)->unsigned()
Most helpful comment
This data type exists in MySQL only, therefore we did not create a shortcut for it.