Add user index to comment_bank_items

refs EVAL-1677
flag=assignment_comment_library

test-plan:
- run migrations and assert a new user index was added
to the comment_bank_items table and the course, user index
was removed
- revert the migration and assert the course, user index was
added and the user index was removed

Change-Id: Ib7a2619718477a0c06d2db0dce09f2a5f3d81da8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/264857
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Pat Renner 2021-05-12 16:22:48 -05:00
parent c0d3dc25ee
commit 28e55e9dd1
1 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,49 @@
# 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 AddUserIndexCommentBankItems < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
tag :predeploy
def change
remove_index :comment_bank_items,
algorithm: :concurrently,
column: [:course_id, :user_id],
where: "workflow_state <> 'deleted'",
name: :index_comment_bank_items_on_course_and_user,
if_exists: true
add_index :comment_bank_items,
:user_id,
algorithm: :concurrently,
name: 'index_active_comment_bank_items_on_user',
where: "workflow_state <> 'deleted'",
if_not_exists: true
add_index :comment_bank_items,
:course_id,
algorithm: :concurrently,
if_not_exists: true
add_index :comment_bank_items,
:user_id,
algorithm: :concurrently,
if_not_exists: true
end
end