Merge branch '21535-multi-wf-delete'
[arvados.git] / services / api / lib / migrate_yaml_to_json.rb
index 1db7ed0113e27cf8fad51e5c83a2d7153f5ccca0..8987f3364c245a04a988697c9c45510ef75bd9a8 100644 (file)
@@ -8,7 +8,7 @@ module MigrateYAMLToJSON
     n = conn.update(
       "UPDATE #{table} SET #{column}=$1 WHERE #{column}=$2",
       "#{table}.#{column} convert YAML to JSON",
-      [[nil, "{}"], [nil, "--- {}\n"]])
+      ["{}", "--- {}\n"])
     Rails.logger.info("#{table}.#{column}: #{n} rows updated using empty hash")
     finished = false
     while !finished
@@ -16,14 +16,14 @@ module MigrateYAMLToJSON
       conn.exec_query(
         "SELECT id, #{column} FROM #{table} WHERE #{column} LIKE $1 LIMIT 100",
         "#{table}.#{column} check for YAML",
-        [[nil, '---%']],
+        ['---%'],
       ).rows.map do |id, yaml|
         n += 1
-        json = SafeJSON.dump(YAML.load(yaml))
+        json = SafeJSON.dump(YAML.safe_load(yaml))
         conn.exec_query(
           "UPDATE #{table} SET #{column}=$1 WHERE id=$2 AND #{column}=$3",
           "#{table}.#{column} convert YAML to JSON",
-          [[nil, json], [nil, id], [nil, yaml]])
+          [json, id, yaml])
       end
       Rails.logger.info("#{table}.#{column}: #{n} rows updated")
       finished = (n == 0)