17417: Merge branch 'main' into 17417-add-arm64
[arvados.git] / services / api / db / migrate / 20211027154300_delete_disabled_user_tokens_and_keys.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class DeleteDisabledUserTokensAndKeys < ActiveRecord::Migration[5.2]
6   def up
7     execute "delete from api_client_authorizations where user_id in (select id from users where is_active ='false' and uuid not like '%-tpzed-anonymouspublic' and uuid not like '%-tpzed-000000000000000')"
8     execute "delete from authorized_keys where owner_uuid in (select uuid from users where is_active ='false' and uuid not like '%-tpzed-anonymouspublic' and uuid not like '%-tpzed-000000000000000')"
9     execute "delete from authorized_keys where authorized_user_uuid in (select uuid from users where is_active ='false' and uuid not like '%-tpzed-anonymouspublic' and uuid not like '%-tpzed-000000000000000')"
10   end
11
12   def down
13     # This migration is not reversible.
14   end
15 end