ruby on rails - How to migrate from ActiveRecord's Serialize Array to Postgres Array datatype -


rails 4 supports postgres' array data type, , want start taking advantage of array types in postgres , how can migrate existing activerecord serialized array field new data type?

serialize stores things inside database yaml documents in text column. yaml isn't easiest format work inside database straightforward approach to:

  1. add array column hold arrays.
  2. loop through each record in rails, let activerecord unserialize yaml, copy ruby arrays serialize column real array column 1.
  3. remove serialize declaration model.
  4. drop old column serialize used.
  5. rename column 1.
  6. set newly renamed column not null if desired.

you parse yaml inside database using regex , string functions depend on sorts of things you're storing in yaml.


Comments

Popular posts from this blog

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -

SQL Server - MyCTE query based on 24 hour period (next day) -