canvas-lms/db/migrate/20160510211116_multiple_gra...

34 lines
1.1 KiB
Ruby
Raw Normal View History

#
# Copyright (C) 2016 - 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 MultipleGradingPeriodsDataMigration < ActiveRecord::Migration[4.2]
migrate grading periods to enrollment terms * associate enrollment terms with root account grading periods * copy sub-account grading periods to the course level for courses that do not currently have grading periods * delete all sub-account grading period groups and grading periods closes CNVS-26724 test plan: 1) create an account, and make 3 grading periods and 3 enrollment terms (Root Account) 2) create a sub-account, and make 3 grading periods (Sub Account 1) 3) create a sub-account of Sub Account 1, and make 3 grading periods (Sub Account 2) 4) create a sub-account of Sub Account 1, and do not make any grading periods (Sub Account 3) 4) create a course that belongs to Sub Account 2 and make 3 grading periods (Course 1) 5) create another course that belongs to Sub Account 2 and do not make any grading periods. (Course 2) 6) create a course that belongs to Sub Account 3 and make 3 grading periods (Course 3) 7) create a course that belongs to Sub Account 3 and do not make any grading periods (Course 4) 8) create a course that belongs to Sub Account 1 and make 3 grading periods (Course 5) 9) create a course that belongs to Sub Account 1 and do not make any grading periods (Course 6) 10)create a course that belongs to Root Account and do not make any grading periods (Course 7) 11)run the migration and verify it completes $ bundle exec rake db:migrate 12)verify the following: * Root Account - still has 3 grading periods - all of its enrollment terms have the same 3 grading periods associated with them * Sub Account 1 - no longer has any grading period groups or grading periods * Sub Account 2 - no longer has any grading period groups or grading periods * Sub Account 3 - still has no grading period groups or grading periods * Course 1 - has the same 3 grading periods it had before running the migration * Course 2 - now has 3 grading periods that match the grading periods Sub Account 2 had before the migration was run * Course 3 - has the same 3 grading periods it had before running the migration * Course 4 - now has 3 grading periods that match the grading periods Sub Account 1 had before the migration was run * Course 5 - has the same 3 grading periods it had before running the migration * Course 6 - now has 3 grading periods that match the grading periods Sub Account 1 had before the migration was run * Course 7 - still has no grading period groups or grading periods Change-Id: Idf94a04e51b965cbc51ee9de419da3ee4e255950 Reviewed-on: https://gerrit.instructure.com/79520 Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Jenkins Reviewed-by: Cameron Matheson <cameron@instructure.com> Reviewed-by: Derek Bender <djbender@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-04-26 01:20:17 +08:00
tag :postdeploy
def up
DataFixup::MultipleGradingPeriodsDataMigration.send_later_if_production_enqueue_args(
:run,
priority: Delayed::LOW_PRIORITY,
strand: "multiple_grading_periods_data_migration",
max_attempts: 1
)
end
def self.down
raise ActiveRecord::IrreversibleMigration
end
end