Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Saying No to NoSQL

Saying No to NoSQL

Migrating a production system from Mongo to Postgres Without losing your mind or your data.

Avatar for Jonathan Neddenriep

Jonathan Neddenriep

November 01, 2012

Other Decks in Programming

Transcript

  1. Saying No to NoSQL Migrating a production system from Mongo

    to Postgres Without losing your mind or your data Jonathan Neddenriep
  2. account_id = ? mongo_account_id = 4cc67093475061e3d95369d account_id = 4cc67093475061e3d95369d_placeholder mongo_account_id

    = 4cc67093475061e3d95369d account_id = 125612 mongo_account_id = 4cc67093475061e3d95369d
  3. { ... 4cc67093475061e3d95369d => 125612 ... } { ... 4cc67093475061e3d95369d

    => [358, 8256] ... } [ ... 358 => "insert into..." ... ]
  4. Code Conversion Find all instances of things like .gte, .lt,

    .eq, .ne, .any, .only Replace relationships like embeds_many with has_many • •
  5. Three Problems # clean up any apostrophes val = val.gsub(/'/,

    "") unless val.nil? || !val.is_a? (String)