#
# Copyright (C) 2020 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class RemoveFkConstraintsForAssetUserAccesses < ActiveRecord::Migration[5.2]
  tag :predeploy

  def change
    remove_foreign_key :asset_user_accesses, :accounts, column: :root_account_id, if_exists: true
  end
end

Remove RA id FK constraint on asset_user_accesses
Remove RA id FK constraint on asset_user_accesses

Although we're not sure why, there are lots of asset_user_accesses with
a cross-shard context and thus would have a cross-shard root account ID.

flag=none
closes INTEROP-6042

Test plan:
- run migration and make sure you can set root_account_id to a global ID e.g.
  12340000000000123 on a AssetUserAccess
- set it back to null
- run `rake db:migrate:down VERSION=20200730144201` and make sure that you
  cannot set root_account to a global ID anymove

Change-Id: Idf1db168c52e0d76bdaeed9e02466fe465276e89
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/243922
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Reviewed-by: Ryan Hawkins <867bc579926fa7e8ba296eacccde2d03d9fb556c@instructure.com>
Reviewed-by: Ethan Vizitei <73eeb0b2f65d05a906adf3b21ee1f9f5a2aa3c1c@instructure.com>
QA-Review: Ryan Hawkins <867bc579926fa7e8ba296eacccde2d03d9fb556c@instructure.com>
Product-Review: Ethan Vizitei <73eeb0b2f65d05a906adf3b21ee1f9f5a2aa3c1c@instructure.com>
