Migration

I am writing a migration that will alter a column from text to int DEFAULT 0, since all the values in that column should be numbers instead of text. The problem is that there are some values in the column that are text. When I run the following code, it gives me an error:

Code


$this->alterColumn('my_table', my_column', 'int DEFAULT 0');

Error


General error: 1366 Incorrect integer value: 'You' for column 'my_column' at row 6

I could write this migration by iterating through all of the rows and changing any text values to 0 before calling the alterColumn function, but it would be nice if there was a way to have that done automatically during the alterColumn call. Is that, or something like it, possible?