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

  disable_ddl_transaction!

  def change
    add_index :users, :root_account_ids, algorithm: :concurrently, using: :gin, if_not_exists: true
  end
end

Add index to users root_account_ids
Add index to users root_account_ids

Needed for communication_channels backfill (it depends on users being
backfilled to needs the index to efficiently check).

refs INTEROP-6038
flag=none

Test plan:
- run migration up, check index exists on table
- run migration down, check index no longer on table

Change-Id: I27a5001a42bbd52cf630204148cd64900c80a1d5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244273
Reviewed-by: Simon Williams <088e16a1019277b15d58faf0541e11910eb756f6@instructure.com>
Reviewed-by: Ryan Hawkins <867bc579926fa7e8ba296eacccde2d03d9fb556c@instructure.com>
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Product-Review: Evan Battaglia <e557ffdfc4b80aab44858030b0ae5370b86cb7b1@instructure.com>
QA-Review: Ryan Hawkins <867bc579926fa7e8ba296eacccde2d03d9fb556c@instructure.com>
