In Yii2 I wish to create a migration to change the character limit of a varchar column from 255 to 765.
Using $this->alterColumn('my_table', 'text_column', 'string');
will make the column 255 as is. I'm thinking of using mysql to change the column to TEXT instead of Varchar, but is there a way to do this in Yii2?
To run specific migration, you can mark(skip) migrations upto just before one you want run. You can mark migration by using one of following command: Using timestamp to specify the migration yii migrate/mark 150101_185401. Using a string that can be parsed by strtotime() yii migrate/mark "2015-01-01 18:54:01"
Migration is the base class for representing a database migration. Migration is designed to be used together with the "yii migrate" command. Each child class of Migration represents an individual database migration which is identified by the child class name.
Changing varchar
length:
$this->alterColumn('my_table', 'text_column', $this->string(765));
Changing column type to text
:
$this->alterColumn('my_table', 'text_column', $this->text());
You can find more examples in Migrations documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With