X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1e31815d4a0d094633d4acb4f6265d6b8b6e3246..HEAD:/services/api/lib/migrate_yaml_to_json.rb diff --git a/services/api/lib/migrate_yaml_to_json.rb b/services/api/lib/migrate_yaml_to_json.rb index 1db7ed0113..8987f3364c 100644 --- a/services/api/lib/migrate_yaml_to_json.rb +++ b/services/api/lib/migrate_yaml_to_json.rb @@ -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)