Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a Rails Migration be utf-8 instead of my default latin1

I just checked my MySQL tables and I have default set as latin1. Is that generally the default?

How can I make it explicit for all my tables that I want the database to be utf-8?

I know there is a db configuration that can change the default, but I think there is also a way to do it per-migration. How could I permanently set my rails migrations from now on to be utf-8?

Thanks!

like image 688
GeekedOut Avatar asked May 23 '11 23:05

GeekedOut


1 Answers

create_table(:table_name, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8')

like image 70
Olivier L. Avatar answered Oct 08 '22 18:10

Olivier L.