drop root_account_id from conversations tables

This removes the root_account_id from Conversation,
ConversationParticipant, ConversationMessage, and
ConversationMessageParticipant. We are opting to do something similar to
whats already being done in conversation with multiple root account ids
instead.

fixes VICE-549
flag=none

/ ---- ---- \
| Test Plan |
\ ---- ---- /

- Run the migration
  - bundle exec rake db:migrate:up VERSION=20200615170938
- Verify that the Conversation, ConversationParticipant,
  ConversationMessage, and ConversationMessageParticipant tables no
  longer have the `root_account_id` column

Change-Id: I7f736d96556ef86dc033aeb30bb37497809a0a29
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/240320
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Matthew Lemon 2020-06-16 08:44:38 -06:00
parent ed4127c72e
commit e85fa83a78
9 changed files with 15 additions and 108 deletions

View File

@ -17,6 +17,8 @@
# #
class Conversation < ActiveRecord::Base class Conversation < ActiveRecord::Base
self.ignored_columns = %i[root_account_id]
include SimpleTags include SimpleTags
include ModelCache include ModelCache
include SendToStream include SendToStream

View File

@ -19,6 +19,8 @@
require 'atom' require 'atom'
class ConversationMessage < ActiveRecord::Base class ConversationMessage < ActiveRecord::Base
self.ignored_columns = %i[root_account_id]
include HtmlTextHelper include HtmlTextHelper
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers

View File

@ -17,6 +17,8 @@
# #
class ConversationMessageParticipant < ActiveRecord::Base class ConversationMessageParticipant < ActiveRecord::Base
self.ignored_columns = %i[root_account_id]
include SimpleTags include SimpleTags
include Workflow include Workflow

View File

@ -17,6 +17,8 @@
# #
class ConversationParticipant < ActiveRecord::Base class ConversationParticipant < ActiveRecord::Base
self.ignored_columns = %i[root_account_id]
include Workflow include Workflow
include TextHelper include TextHelper
include SimpleTags include SimpleTags

View File

@ -1,31 +0,0 @@
#
# 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 AddRootAccountIdToConversations < ActiveRecord::Migration[5.2]
include MigrationHelpers::AddColumnAndFk
tag :predeploy
disable_ddl_transaction!
def up
add_column_and_fk :conversations, :root_account_id, :accounts, if_not_exists: true
end
def down
remove_column :conversations, :root_account_id
end
end

View File

@ -1,31 +0,0 @@
#
# 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 AddRootAccountIdToConversationParticipants < ActiveRecord::Migration[5.2]
include MigrationHelpers::AddColumnAndFk
tag :predeploy
disable_ddl_transaction!
def up
add_column_and_fk :conversation_participants, :root_account_id, :accounts, if_not_exists: true
end
def down
remove_column :conversation_participants, :root_account_id
end
end

View File

@ -1,31 +0,0 @@
#
# 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 AddRootAccountIdToConversationMessages < ActiveRecord::Migration[5.2]
include MigrationHelpers::AddColumnAndFk
tag :predeploy
disable_ddl_transaction!
def up
add_column_and_fk :conversation_messages, :root_account_id, :accounts, if_not_exists: true
end
def down
remove_column :conversation_messages, :root_account_id
end
end

View File

@ -67,8 +67,6 @@ class AddIndexToRootAccountIds < ActiveRecord::Migration[5.2]
add_index :custom_gradebook_columns, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :custom_gradebook_columns, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :learning_outcome_groups, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :learning_outcome_groups, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :custom_gradebook_column_data, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :custom_gradebook_column_data, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :conversations, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :conversation_participants, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :master_courses_master_migrations, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :master_courses_master_migrations, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :learning_outcomes, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :learning_outcomes, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :learning_outcome_question_results, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :learning_outcome_question_results, :root_account_id, algorithm: :concurrently, if_not_exists: true
@ -89,8 +87,6 @@ class AddIndexToRootAccountIds < ActiveRecord::Migration[5.2]
add_index :calendar_events, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :calendar_events, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :folders, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :folders, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :communication_channels, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :communication_channels, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :conversation_messages, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :conversation_message_participants, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :favorites, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :favorites, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :discussion_topics, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :discussion_topics, :root_account_id, algorithm: :concurrently, if_not_exists: true
add_index :discussion_entry_participants, :root_account_id, algorithm: :concurrently, if_not_exists: true add_index :discussion_entry_participants, :root_account_id, algorithm: :concurrently, if_not_exists: true

View File

@ -14,18 +14,14 @@
# #
# You should have received a copy of the GNU Affero General Public License along # 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/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
#
class AddRootAccountIdToConversationMessageParticipants < ActiveRecord::Migration[5.2]
include MigrationHelpers::AddColumnAndFk
tag :predeploy class DropRootAccountIdFromConversationsTables < ActiveRecord::Migration[5.2]
disable_ddl_transaction! tag :postdeploy
def up def change
add_column_and_fk :conversation_message_participants, :root_account_id, :accounts, if_not_exists: true remove_column :conversations, :root_account_id if column_exists?(:conversations, :root_account_id)
end remove_column :conversation_participants, :root_account_id if column_exists?(:conversation_participants, :root_account_id)
remove_column :conversation_messages, :root_account_id if column_exists?(:conversation_messages, :root_account_id)
def down remove_column :conversation_message_participants, :root_account_id if column_exists?(:conversation_message_participants, :root_account_id)
remove_column :conversation_message_participants, :root_account_id
end end
end end