Handle non-nil, empty Instances return refs #20978
[arvados.git] / services / api / db / migrate / 20220726034131_write_via_all_users.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class WriteViaAllUsers < ActiveRecord::Migration[5.2]
6   include CurrentApiClient
7   def up
8     changelinks(from: "can_read", to: "can_write")
9   end
10   def down
11     changelinks(from: "can_write", to: "can_read")
12   end
13   def changelinks(from:, to:)
14     ActiveRecord::Base.connection.exec_query(
15       "update links set name=$1 where link_class=$2 and name=$3 and tail_uuid like $4 and head_uuid = $5",
16       "migrate", [
17         [nil, to],
18         [nil, "permission"],
19         [nil, from],
20         [nil, "_____-tpzed-_______________"],
21         [nil, all_users_group_uuid],
22       ])
23   end
24 end