在Yii2中,我希望创建一个迁移,将varchar列的字符限制从255更改为765.
使用$this->alterColumn('my_table', 'text_column', 'string');
将使列255保持原样。我正在考虑使用mysql将列更改为 TEXT 而不是 Varchar ,但有没有办法在Yii2中执行此操作?
答案 0 :(得分:5)
更改varchar
长度:
$this->alterColumn('my_table', 'text_column', $this->string(765));
将列类型更改为text
:
$this->alterColumn('my_table', 'text_column', $this->text());
您可以在Migrations documentation中找到更多示例。