# frozen_string_literal: true

# Copyright (C) 2022 - 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 ChangeDiscussionTopicMaterializedViewsFieldsToText < ActiveRecord::Migration[6.1]
  tag :predeploy

  def up
    change_column :discussion_topic_materialized_views, :json_structure, :text, limit: nil
    change_column :discussion_topic_materialized_views, :participants_array, :text, limit: nil
    change_column :discussion_topic_materialized_views, :entry_ids_array, :text, limit: nil
  end

  def down
    change_column :discussion_topic_materialized_views, :json_structure, :text, limit: 10.megabytes
    change_column :discussion_topic_materialized_views, :participants_array, :text, limit: 10.megabytes
    change_column :discussion_topic_materialized_views, :entry_ids_array, :text, limit: 10.megabytes
  end
end

Change discussion_topic_materialized_views fields to text
Change discussion_topic_materialized_views fields to text

flag=none
closes VICE-3126

test plan:
  - Tests pass
  - Cursory testing of legacy discussions

qa risk: low

Change-Id: Ifc84cbeadb439b919bc84d5cae400b92ff32eb0b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/302961
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Migration-Review: Jeremy Stanley <b3f594e10a9edcf5413cf1190121d45078c62290@instructure.com>
QA-Review: Caleb Guanzon <54fa1f30d451e4f3c341a8f3c47c9215fd0be9c6@instructure.com>
Reviewed-by: Chawn Neal <908eabd8c84ff6c7c139535b8d37802d58ad1683@instructure.com>
Product-Review: Chawn Neal <908eabd8c84ff6c7c139535b8d37802d58ad1683@instructure.com>
