# frozen_string_literal: true
#
# Copyright (C) 2021 - 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 AddReplicaIdentityForRoles < ActiveRecord::Migration[6.0]
  tag :postdeploy
  disable_ddl_transaction!

  def up
    add_replica_identity 'Role', :root_account_id, 0
    remove_index :roles, column: :root_account_id, if_exists: true
  end

  def down
    add_index :roles, :root_account_id, algorithm: :concurrently, if_not_exists: true
    remove_replica_identity 'Role'
  end
end

Set up replica identity index for Role
Set up replica identity index for Role

refs FOO-1171
flag=none

test plan:
 - migration works up and down
 - tests pass

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