#
# 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 RemoveFkConstraintsForMoreCrossShardRootAccountIds < ActiveRecord::Migration[5.2]
  tag :predeploy

  def change
    remove_foreign_key :access_tokens, :accounts, column: :root_account_id, if_exists: true
    remove_foreign_key :rubric_associations, :accounts, column: :root_account_id, if_exists: true
  end
end

Remove FK constraints for more global RA ids
Remove FK constraints for more global RA ids

root_account_id on these tables can be cross-shard, so cannot have an FK
constraint.

flag=none
closes INTEROP-6006

Test plan:
- run migration and make sure you can set root_account_id to a global ID e.g.
  10000000000001 on a AccessToken and RubricAssociation
- run `rake db:migrate:down VERSION=20200713144312` and make sure that you
  cannot set root_account to a global ID anymove

Change-Id: I5ea00506f9eacba4ff0106133bcd0e8dcbaa6dc1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242539
QA-Review: Cody Cutrer <c4fe2b1d90ef8f2548c8aeabfa633434316f0305@instructure.com>
Product-Review: Cody Cutrer <c4fe2b1d90ef8f2548c8aeabfa633434316f0305@instructure.com>
Reviewed-by: Weston Dransfield <e9203059795dc94e28a8831c65eb7869e818825e@instructure.com>
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
