X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e5ed756501133df3fbcce69399da46439a8d3e6c..5be45d68cc47f06314339cc8aac9e39ae267ef85:/services/api/db/migrate/20141208174653_collection_file_names.rb diff --git a/services/api/db/migrate/20141208174653_collection_file_names.rb b/services/api/db/migrate/20141208174653_collection_file_names.rb index 51b474612d..7abd778c04 100644 --- a/services/api/db/migrate/20141208174653_collection_file_names.rb +++ b/services/api/db/migrate/20141208174653_collection_file_names.rb @@ -1,15 +1,19 @@ -class CollectionFileNames < ActiveRecord::Migration +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +class CollectionFileNames < ActiveRecord::Migration[4.2] include CurrentApiClient def up add_column :collections, :file_names, :string, :limit => 2**13 act_as_system_user do - Collection.all.each do |c| - if c.manifest_text - file_names = Collection.manifest_files c.manifest_text - update_sql "UPDATE collections SET file_names = '#{file_names}' WHERE uuid = '#{c.uuid}'" - end + Collection.find_each(batch_size: 20) do |c| + file_names = c.manifest_files + ActiveRecord::Base.connection.execute "UPDATE collections + SET file_names = #{ActiveRecord::Base.connection.quote(file_names)} + WHERE uuid = '#{c.uuid}'" end end end