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

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -