Skip to content

Fixing Old Database Seeds

Steve McDonald edited this page Oct 6, 2015 · 1 revision

How to fix the old seeds database encoding?

  1. Do a data dump from MySQL

  2. Convert the data dump to UTF-8

    iconv -f UTF-8 -t UTF-8 jedarchi_seeds_2012-06-13.sql > trans-jda-latin-utf.sql sed -e's/latin1/utf8/g' transf-jda-latin-utf.sql > transf-jda-latin-utf-fixed.sql

  3. Create a MySQL database with the encoding set to UTF-8

  4. Run the following scripts

    drop index title on seeds; drop index description on seeds; drop index tags on seeds;

    ALTER TABLE seeds MODIFY title varchar(255) CHARACTER SET latin1; ALTER TABLE seeds MODIFY title BLOB; ALTER TABLE seeds MODIFY title varchar(255) CHARACTER SET utf8;

    ALTER TABLE seeds MODIFY description text CHARACTER SET latin1; ALTER TABLE seeds MODIFY description BLOB; ALTER TABLE seeds MODIFY description text CHARACTER SET utf8;

    ALTER TABLE seeds MODIFY name varchar(255) CHARACTER SET latin1; ALTER TABLE seeds MODIFY name BLOB; ALTER TABLE seeds MODIFY name varchar(255) CHARACTER SET utf8;

    ALTER TABLE seeds MODIFY tags text CHARACTER SET latin1; ALTER TABLE seeds MODIFY tags BLOB; ALTER TABLE seeds MODIFY tags text CHARACTER SET utf8;

    ALTER TABLE seeds MODIFY location text CHARACTER SET latin1; ALTER TABLE seeds MODIFY location BLOB; ALTER TABLE seeds MODIFY location text CHARACTER SET utf8;

    drop index name from tags;

    ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET latin1; ALTER TABLE tags MODIFY name BLOB; ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial_image MODIFY address varchar(255) CHARACTER SET latin1; ALTER TABLE testimonial_image MODIFY address BLOB; ALTER TABLE testimonial_image MODIFY address varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial_image_tag MODIFY tag varchar(255) CHARACTER SET latin1; ALTER TABLE testimonial_image_tag MODIFY tag BLOB; ALTER TABLE testimonial_image_tag MODIFY tag varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial_location MODIFY name varchar(255) CHARACTER SET latin1; ALTER TABLE testimonial_location MODIFY name BLOB; ALTER TABLE testimonial_location MODIFY name varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial MODIFY name varchar(255) CHARACTER SET latin1; ALTER TABLE testimonial MODIFY name BLOB; ALTER TABLE testimonial MODIFY name varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial MODIFY city varchar(255) CHARACTER SET latin1; ALTER TABLE testimonial MODIFY city BLOB; ALTER TABLE testimonial MODIFY city varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial MODIFY occupation varchar(255) CHARACTER SET latin1; ALTER TABLE testimonial MODIFY occupation BLOB; ALTER TABLE testimonial MODIFY occupation varchar(255) CHARACTER SET utf8;

    ALTER TABLE testimonial MODIFY story text CHARACTER SET latin1; ALTER TABLE testimonial MODIFY story BLOB; ALTER TABLE testimonial MODIFY story text CHARACTER SET utf8;