2

I have a field in a database that is serialized (sadly) into Yaml.

Below is the field definition on the table:

  class Account < Sequel::Model
    include ModelManager

    plugin :serialization

    serialize_attributes :yaml, :billing_info

I would really like to transform this into the new json type but we are still on postgres 9.2.6.

Is there anyway that I can query this data until I can migrate it?

The field either contains an empty definition like this:

--- !ruby/object:BillingInfo {}

Or has data like this:

--- !ruby/object:BillingInfo
gateway_identifier: blah 
organisation: blah
billing_email: blah
reference: blah
phone: blah
country: blah
vat: blah
subscription: blah
dagda1
  • 26,856
  • 59
  • 237
  • 450

1 Answers1

1

If you mean query at the PostgreSQL level, you'll have to add your own yaml parser, using something like plv8 and js-yaml as explained here:

Store and index YAML with PostgreSQL, with Javascript lib or reusable functions?

Community
  • 1
  • 1
Jeremy Evans
  • 11,959
  • 27
  • 26