Rails Migration change from boolean to specific string

Viewed 32

I am trying to run a migration to change the type of a column from boolean to string and also assign a specific string value if it was true and another one if it was false

What I am trying and does not work:

def change
  change_column :people, :owner, :string, using: "CASE WHEN owner THEN 'foo' ELSE 'bar' END"
end

The migration runs without errors but true is converted to "1" and false to "0" and not to the strings that I specified. Database is mysql if relevant.

0 Answers
Related