squash old migrations, p16

Change-Id: I78da2371145e3744b9570d8781f353d7b3185778
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/227060
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:
Simon Williams 2020-02-18 14:02:34 -06:00
parent 9e70974239
commit d45a35951d
49 changed files with 335 additions and 2477 deletions

View File

@ -28,7 +28,7 @@ class ValidateMigrationIntegrity < ActiveRecord::Migration[4.2]
def self.up
initial_migration_version = "20101210192618"
last_squashed_migration_version = "20130730164252"
last_squashed_migration_version = "20131105175802"
initial_migration_has_run = ActiveRecord::SchemaMigration.where(version: initial_migration_version).exists?
last_squashed_migration_has_run = ActiveRecord::SchemaMigration.where(version: last_squashed_migration_version).exists?

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,8 @@ class AddCassandraPageViewTables < ActiveRecord::Migration[4.2]
summarized boolean,
account_id bigint,
real_user_id bigint,
http_method text
http_method text,
remote_ip text
) #{compression_params}}
cassandra.execute %{

View File

@ -29,6 +29,10 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2]
authentications_by_pseudonym
authentications_by_account
authentications_by_user
grade_changes_by_assignment
grade_changes_by_course
grade_changes_by_root_account_student
grade_changes_by_root_account_grader
)
end
@ -47,6 +51,24 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2]
event_type text
) #{compression_params}}
cassandra.execute %{
CREATE TABLE grade_changes (
id text PRIMARY KEY,
created_at timestamp,
request_id text,
account_id bigint,
submission_id bigint,
version_number int,
grader_id bigint,
student_id bigint,
assignment_id bigint,
context_id bigint,
context_type text,
event_type text,
grade_before text,
grade_after text
) #{compression_params}}
indexes.each do |index_name|
cassandra.execute %{
CREATE TABLE #{index_name} (
@ -64,5 +86,6 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2]
end
cassandra.execute %{DROP TABLE authentications;}
cassandra.execute %{DROP TABLE grade_changes;}
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 AddSubjectToConversationBatch < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :conversation_batches, :subject, :string
end
def self.down
remove_column :conversation_batches, :subject
end
end

View File

@ -1,471 +0,0 @@
#
# Copyright (C) 2013 - 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 MakeColumnsNotNull < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
tag :postdeploy
def self.up
change_column_null :abstract_courses, :workflow_state, false
change_column_null :abstract_courses, :account_id, false
change_column_null :abstract_courses, :root_account_id, false
AbstractCourse.where(enrollment_term_id: nil).find_each do |ac|
AbstractCourse.where(id: ac).update_all(enrollment_term_id: ac.root_account.default_enrollment_term.id)
end
change_column_null :abstract_courses, :enrollment_term_id, false
change_column_null :account_authorization_configs, :account_id, false
change_column_null :account_notifications, :start_at, false
change_column_null :account_notifications, :end_at, false
change_column_null :account_notifications, :account_id, false
change_column_null :account_users, :account_id, false
change_column_null :account_users, :user_id, false
change_column_null :account_users, :membership_type, false
change_column_null :account_reports, :account_id, false
change_column_null :account_reports, :user_id, false
change_column_null :account_reports, :workflow_state, false
change_column_null :accounts, :workflow_state, false
change_column_null :alerts, :context_id, false
change_column_null :alerts, :context_type, false
change_column_null :alerts, :recipients, false
change_column_null :appointment_groups, :workflow_state, false
change_column_null :assessment_question_bank_users, :workflow_state, false
change_column_null :assessment_question_bank_users, :user_id, false
change_column_null :assessment_question_bank_users, :assessment_question_bank_id, false
change_column_null :assessment_question_banks, :workflow_state, false
change_column_null :assessment_requests, :workflow_state, false
change_column_null :assessment_requests, :user_id, false
change_column_null :assessment_requests, :asset_id, false
change_column_null :assessment_requests, :asset_type, false
change_column_null :assessment_requests, :assessor_asset_id, false
change_column_null :assessment_requests, :assessor_asset_type, false
change_column_null :assessment_requests, :assessor_id, false
change_column_null :assignments, :context_type, false
change_column_null :assignments, :context_id, false
change_column_null :assignments, :workflow_state, false
change_column_null :assignment_groups, :context_id, false
change_column_null :assignment_groups, :context_type, false
change_column_null :assignment_groups, :workflow_state, false
change_column_null :assignment_overrides, :title, false
change_column_null :calendar_events, :context_id, false
change_column_null :calendar_events, :context_type, false
change_column_null :calendar_events, :workflow_state, false
change_column_null :collaborations, :title, false
change_column_null :collaborations, :workflow_state, false
change_column_null :collections, :workflow_state, false
change_column_null :collections, :context_id, false
change_column_null :collections, :context_type, false
change_column_null :collection_items, :collection_id, false
change_column_null :collection_items, :collection_item_data_id, false
change_column_null :collection_items, :user_id, false
change_column_null :collection_items, :workflow_state, false
change_column_null :collection_item_datas, :link_url, false
change_column_null :collection_item_upvotes, :collection_item_data_id, false
change_column_null :collection_item_upvotes, :user_id, false
change_column_null :communication_channels, :path, false
change_column_null :communication_channels, :path_type, false
change_column_null :communication_channels, :user_id, false
change_column_null :communication_channels, :workflow_state, false
change_column_null :content_exports, :workflow_state, false
change_column_null :content_exports, :course_id, false
change_column_null :content_migrations, :workflow_state, false
change_column_null :content_migrations, :context_id, false
change_column_null :content_participations, :workflow_state, false
change_column_null :content_participations, :content_id, false
change_column_null :content_participations, :content_type, false
change_column_null :content_participations, :user_id, false
change_column_null :content_tags, :context_type, false
change_column_null :content_tags, :context_id, false
change_column_null :content_tags, :workflow_state, false
change_column_null :context_external_tools, :name, false
change_column_null :context_external_tools, :consumer_key, false
change_column_null :context_external_tools, :shared_secret, false
change_column_null :context_external_tools, :workflow_state, false
change_column_null :context_module_progressions, :workflow_state, false
change_column_null :context_modules, :workflow_state, false
change_column_null :context_modules, :context_id, false
change_column_null :context_modules, :context_type, false
change_column_null :conversation_batches, :workflow_state, false
change_column_null :conversation_batches, :user_id, false
ConversationBatch.where(root_conversation_message_id: nil).delete_all
change_column_null :conversation_batches, :root_conversation_message_id, false
change_column_null :conversation_participants, :workflow_state, false
change_column_null :conversation_participants, :conversation_id, false
change_column_null :conversation_participants, :user_id, false
change_column_null :course_account_associations, :depth, false
change_column_null :course_account_associations, :course_id, false
change_column_null :course_account_associations, :account_id, false
change_column_null :course_sections, :course_id, false
change_column_null :course_sections, :root_account_id, false
change_column_null :course_sections, :workflow_state, false
change_column_null :courses, :workflow_state, false
change_column_null :courses, :account_id, false
change_column_null :courses, :root_account_id, false
change_column_null :courses, :enrollment_term_id, false
change_column_null :delayed_notifications, :workflow_state, false
change_column_null :delayed_notifications, :notification_id, false
change_column_null :delayed_notifications, :asset_id, false
change_column_null :delayed_notifications, :asset_type, false
change_column_null :discussion_entry_participants, :workflow_state, false
change_column_null :discussion_entry_participants, :user_id, false
change_column_null :discussion_entry_participants, :discussion_entry_id, false
change_column_null :discussion_topic_participants, :workflow_state, false
change_column_null :discussion_topic_participants, :user_id, false
change_column_null :discussion_topic_participants, :discussion_topic_id, false
change_column_null :discussion_topic_participants, :unread_entry_count, false
change_column_null :discussion_topics, :context_type, false
change_column_null :discussion_topics, :context_id, false
change_column_null :discussion_topics, :workflow_state, false
change_column_null :enrollment_terms, :root_account_id, false
change_column_null :enrollment_terms, :workflow_state, false
change_column_null :enrollments, :user_id, false
change_column_null :enrollments, :course_id, false
change_column_null :enrollments, :type, false
change_column_null :enrollments, :root_account_id, false
Enrollment.where(course_section_id: nil).find_each do |e|
Enrollment.where(id: e).update_all(course_section_id: e.course.default_section.id)
end
change_column_null :enrollments, :course_section_id, false
change_column_null :enrollments, :workflow_state, false
change_column_null :eportfolios, :user_id, false
change_column_null :eportfolios, :workflow_state, false
change_column_null :eportfolio_categories, :eportfolio_id, false
change_column_null :eportfolio_entries, :eportfolio_id, false
change_column_null :eportfolio_entries, :eportfolio_category_id, false
change_column_null :external_feed_entries, :workflow_state, false
change_column_null :external_feed_entries, :external_feed_id, false
change_column_null :external_feeds, :url, false
change_column_null :external_feeds, :context_id, false
change_column_null :external_feeds, :context_type, false
change_column_null :folders, :context_type, false
change_column_null :folders, :context_id, false
change_column_null :folders, :workflow_state, false
change_column_null :grading_standards, :workflow_state, false
change_column_null :grading_standards, :context_id, false
change_column_null :grading_standards, :context_type, false
change_column_null :group_memberships, :group_id, false
change_column_null :group_memberships, :user_id, false
change_column_null :group_memberships, :workflow_state, false
change_column_null :groups, :context_id, false
change_column_null :groups, :context_type, false
change_column_null :groups, :account_id, false
change_column_null :groups, :root_account_id, false
change_column_null :groups, :workflow_state, false
LearningOutcome.where(short_description: nil).update_all(short_description: '')
change_column_null :learning_outcomes, :short_description, false
change_column_null :learning_outcomes, :workflow_state, false
LearningOutcomeGroup.where(title: nil).update_all(title: '')
change_column_null :learning_outcome_groups, :title, false
change_column_null :learning_outcome_groups, :workflow_state, false
change_column_null :media_objects, :workflow_state, false
change_column_null :media_objects, :media_id, false
change_column_null :media_tracks, :media_object_id, false
change_column_null :media_tracks, :content, false
change_column_null :migration_issues, :workflow_state, false
change_column_null :migration_issues, :content_migration_id, false
change_column_null :migration_issues, :issue_type, false
change_column_null :notification_policies, :communication_channel_id, false
change_column_null :notification_policies, :broadcast, false
change_column_null :notifications, :workflow_state, false
change_column_null :page_views, :user_id, false
change_column_null :profiles, :root_account_id, false
change_column_null :profiles, :context_id, false
change_column_null :profiles, :context_type, false
change_column_null :progresses, :context_id, false
change_column_null :progresses, :context_type, false
change_column_null :progresses, :workflow_state, false
change_column_null :pseudonyms, :workflow_state, false
change_column_null :pseudonyms, :account_id, false
Pseudonym.where(user_id: nil).delete_all
change_column_null :pseudonyms, :user_id, false
change_column_null :quizzes, :context_id, false
change_column_null :quizzes, :context_type, false
change_column_null :quizzes, :workflow_state, false
change_column_null :quiz_groups, :quiz_id, false
change_column_null :quiz_submissions, :workflow_state, false
change_column_null :quiz_submissions, :quiz_id, false
change_column_null :roles, :workflow_state, false
change_column_null :rubric_assessments, :assessment_type, false
change_column_null :rubric_assessments, :rubric_id, false
change_column_null :rubric_assessments, :artifact_id, false
change_column_null :rubric_assessments, :artifact_type, false
change_column_null :rubric_associations, :purpose, false
change_column_null :rubric_associations, :rubric_id, false
change_column_null :rubric_associations, :association_id, false
change_column_null :rubric_associations, :association_type, false
change_column_null :rubric_associations, :context_id, false
change_column_null :rubric_associations, :context_type, false
change_column_null :rubrics, :workflow_state, false
change_column_null :rubrics, :context_id, false
change_column_null :rubrics, :context_type, false
change_column_null :session_persistence_tokens, :crypted_token, false
change_column_null :session_persistence_tokens, :pseudonym_id, false
change_column_null :session_persistence_tokens, :token_salt, false
change_column_null :sis_batches, :workflow_state, false
change_column_null :sis_batches, :account_id, false
change_column_null :stream_items, :data, false
change_column_null :stream_items, :asset_type, false
change_column_null :stream_item_instances, :user_id, false
change_column_null :stream_item_instances, :stream_item_id, false
change_column_null :submissions, :assignment_id, false
change_column_null :submissions, :user_id, false
change_column_null :submissions, :workflow_state, false
change_column_null :thumbnails, :size, false
change_column_null :thumbnails, :content_type, false
change_column_null :thumbnails, :filename, false
change_column_null :user_account_associations, :user_id, false
change_column_null :user_account_associations, :account_id, false
change_column_null :user_follows, :following_user_id, false
change_column_null :user_follows, :followed_item_id, false
change_column_null :user_notes, :workflow_state, false
change_column_null :user_services, :user_id, false
change_column_null :user_services, :service, false
UserService.where(service_user_id: nil).delete_all
change_column_null :user_services, :service_user_id, false
change_column_null :user_services, :workflow_state, false
change_column_null :users, :workflow_state, false
change_column_null :web_conferences, :conference_type, false
change_column_null :web_conferences, :title, false
change_column_null :web_conferences, :context_id, false
change_column_null :web_conferences, :context_type, false
change_column_null :web_conferences, :user_id, false
change_column_null :wiki_pages, :workflow_state, false
change_column_null :wiki_pages, :wiki_id, false
change_column_null :zip_file_imports, :context_id, false
change_column_null :zip_file_imports, :context_type, false
change_column_null :zip_file_imports, :workflow_state, false
end
def self.down
change_column_null :abstract_courses, :workflow_state, true
change_column_null :abstract_courses, :account_id, true
change_column_null :abstract_courses, :root_account_id, true
change_column_null :abstract_courses, :enrollment_term_id, true
change_column_null :account_authorization_configs, :account_id, true
change_column_null :account_notifications, :start_at, true
change_column_null :account_notifications, :end_at, true
change_column_null :account_notifications, :account_id, true
change_column_null :account_users, :account_id, true
change_column_null :account_users, :user_id, true
change_column_null :account_users, :membership_type, true
change_column_null :account_reports, :account_id, true
change_column_null :account_reports, :user_id, true
change_column_null :account_reports, :workflow_state, true
change_column_null :accounts, :workflow_state, true
change_column_null :alerts, :context_id, true
change_column_null :alerts, :context_type, true
change_column_null :alerts, :recipients, true
change_column_null :appointment_groups, :workflow_state, true
change_column_null :assessment_question_bank_users, :workflow_state, true
change_column_null :assessment_question_bank_users, :user_id, true
change_column_null :assessment_question_bank_users, :assessment_question_bank_id, true
change_column_null :assessment_question_banks, :workflow_state, true
change_column_null :assessment_requests, :workflow_state, true
change_column_null :assessment_requests, :user_id, true
change_column_null :assessment_requests, :asset_id, true
change_column_null :assessment_requests, :asset_type, true
change_column_null :assessment_requests, :assessor_asset_id, true
change_column_null :assessment_requests, :assessor_asset_type, true
change_column_null :assessment_requests, :assessor_id, true
change_column_null :assignments, :context_type, true
change_column_null :assignments, :context_id, true
change_column_null :assignments, :workflow_state, true
change_column_null :assignment_groups, :context_id, true
change_column_null :assignment_groups, :context_type, true
change_column_null :assignment_groups, :workflow_state, true
change_column_null :assignment_overrides, :title, true
change_column_null :calendar_events, :context_id, true
change_column_null :calendar_events, :context_type, true
change_column_null :calendar_events, :workflow_state, true
change_column_null :collaborations, :title, true
change_column_null :collaborations, :workflow_state, true
change_column_null :collections, :workflow_state, true
change_column_null :collections, :context_id, true
change_column_null :collections, :context_type, true
change_column_null :collection_items, :collection_id, true
change_column_null :collection_items, :collection_item_data_id, true
change_column_null :collection_items, :user_id, true
change_column_null :collection_items, :workflow_state, true
change_column_null :collection_item_datas, :link_url, true
change_column_null :collection_item_upvotes, :collection_item_data_id, true
change_column_null :collection_item_upvotes, :user_id, true
change_column_null :communication_channels, :path, true
change_column_null :communication_channels, :path_type, true
change_column_null :communication_channels, :user_id, true
change_column_null :communication_channels, :workflow_state, true
change_column_null :content_exports, :workflow_state, true
change_column_null :content_exports, :course_id, true
change_column_null :content_migrations, :workflow_state, true
change_column_null :content_migrations, :context_id, true
change_column_null :content_participations, :workflow_state, true
change_column_null :content_participations, :content_id, true
change_column_null :content_participations, :content_type, true
change_column_null :content_participations, :user_id, true
change_column_null :content_tags, :context_type, true
change_column_null :content_tags, :context_id, true
change_column_null :content_tags, :workflow_state, true
change_column_null :context_external_tools, :name, true
change_column_null :context_external_tools, :consumer_key, true
change_column_null :context_external_tools, :shared_secret, true
change_column_null :context_external_tools, :workflow_state, true
change_column_null :context_module_progressions, :workflow_state, true
change_column_null :context_modules, :workflow_state, true
change_column_null :context_modules, :context_id, true
change_column_null :context_modules, :context_type, true
change_column_null :conversation_batches, :workflow_state, true
change_column_null :conversation_batches, :user_id, true
change_column_null :conversation_batches, :root_conversation_message_id, true
change_column_null :conversation_participants, :workflow_state, true
change_column_null :conversation_participants, :conversation_id, true
change_column_null :conversation_participants, :user_id, true
change_column_null :course_account_associations, :depth, true
change_column_null :course_account_associations, :course_id, true
change_column_null :course_account_associations, :account_id, true
change_column_null :course_sections, :course_id, true
change_column_null :course_sections, :root_account_id, true
change_column_null :course_sections, :workflow_state, true
change_column_null :courses, :workflow_state, true
change_column_null :courses, :account_id, true
change_column_null :courses, :root_account_id, true
change_column_null :courses, :enrollment_term_id, true
change_column_null :delayed_notifications, :workflow_state, true
change_column_null :delayed_notifications, :notification_id, true
change_column_null :delayed_notifications, :asset_id, true
change_column_null :delayed_notifications, :asset_type, true
change_column_null :discussion_entry_participants, :workflow_state, true
change_column_null :discussion_entry_participants, :user_id, true
change_column_null :discussion_entry_participants, :discussion_entry_id, true
change_column_null :discussion_topic_participants, :workflow_state, true
change_column_null :discussion_topic_participants, :user_id, true
change_column_null :discussion_topic_participants, :discussion_topic_id, true
change_column_null :discussion_topic_participants, :unread_entry_count, true
change_column_null :discussion_topics, :context_type, true
change_column_null :discussion_topics, :context_id, true
change_column_null :discussion_topics, :workflow_state, true
change_column_null :enrollment_terms, :root_account_id, true
change_column_null :enrollment_terms, :workflow_state, true
change_column_null :enrollments, :user_id, true
change_column_null :enrollments, :course_id, true
change_column_null :enrollments, :type, true
change_column_null :enrollments, :root_account_id, true
change_column_null :enrollments, :course_section_id, true
change_column_null :enrollments, :workflow_state, true
change_column_null :eportfolios, :user_id, true
change_column_null :eportfolios, :workflow_state, true
change_column_null :eportfolio_categories, :eportfolio_id, true
change_column_null :eportfolio_entries, :eportfolio_id, true
change_column_null :eportfolio_entries, :eportfolio_category_id, true
change_column_null :external_feed_entries, :workflow_state, true
change_column_null :external_feed_entries, :external_feed_id, true
change_column_null :external_feeds, :url, true
change_column_null :external_feeds, :context_id, true
change_column_null :external_feeds, :context_type, true
change_column_null :folders, :context_type, true
change_column_null :folders, :context_id, true
change_column_null :folders, :workflow_state, true
change_column_null :grading_standards, :workflow_state, true
change_column_null :grading_standards, :context_id, true
change_column_null :grading_standards, :context_type, true
change_column_null :group_memberships, :group_id, true
change_column_null :group_memberships, :user_id, true
change_column_null :group_memberships, :workflow_state, true
change_column_null :groups, :context_id, true
change_column_null :groups, :context_type, true
change_column_null :groups, :account_id, true
change_column_null :groups, :root_account_id, true
change_column_null :groups, :workflow_state, true
change_column_null :learning_outcomes, :short_description, true
change_column_null :learning_outcomes, :workflow_state, true
change_column_null :learning_outcome_groups, :title, true
change_column_null :learning_outcome_groups, :workflow_state, true
change_column_null :media_objects, :workflow_state, true
change_column_null :media_objects, :media_id, true
change_column_null :media_tracks, :media_object_id, true
change_column_null :media_tracks, :content, true
change_column_null :migration_issues, :workflow_state, true
change_column_null :migration_issues, :content_migration_id, true
change_column_null :migration_issues, :issue_type, true
change_column_null :notification_policies, :communication_channel_id, true
change_column_null :notification_policies, :broadcast, true
change_column_null :notifications, :workflow_state, true
change_column_null :page_views, :user_id, true
change_column_null :profiles, :root_account_id, true
change_column_null :profiles, :context_id, true
change_column_null :profiles, :context_type, true
change_column_null :progresses, :context_id, true
change_column_null :progresses, :context_type, true
change_column_null :progresses, :workflow_state, true
change_column_null :pseudonyms, :workflow_state, true
change_column_null :pseudonyms, :account_id, true
change_column_null :pseudonyms, :user_id, true
change_column_null :quizzes, :context_id, true
change_column_null :quizzes, :context_type, true
change_column_null :quizzes, :workflow_state, true
change_column_null :quiz_groups, :quiz_id, true
change_column_null :quiz_submissions, :workflow_state, true
change_column_null :quiz_submissions, :quiz_id, true
change_column_null :roles, :workflow_state, true
change_column_null :rubric_assessments, :assessment_type, true
change_column_null :rubric_assessments, :rubric_id, true
change_column_null :rubric_assessments, :rubric_association_id, true
change_column_null :rubric_assessments, :artifact_id, true
change_column_null :rubric_assessments, :artifact_type, true
change_column_null :rubric_associations, :purpose, true
change_column_null :rubric_associations, :rubric_id, true
change_column_null :rubric_associations, :association_id, true
change_column_null :rubric_associations, :association_type, true
change_column_null :rubric_associations, :context_id, true
change_column_null :rubric_associations, :context_type, true
change_column_null :rubrics, :workflow_state, true
change_column_null :rubrics, :context_id, true
change_column_null :rubrics, :context_type, true
change_column_null :session_persistence_tokens, :crypted_token, true
change_column_null :session_persistence_tokens, :pseudonym_id, true
change_column_null :session_persistence_tokens, :token_salt, true
change_column_null :sis_batches, :workflow_state, true
change_column_null :sis_batches, :account_id, true
change_column_null :stream_items, :data, true
change_column_null :stream_items, :asset_type, true
change_column_null :stream_item_instances, :user_id, true
change_column_null :stream_item_instances, :stream_item_id, true
change_column_null :submissions, :assignment_id, true
change_column_null :submissions, :user_id, true
change_column_null :submissions, :workflow_state, true
change_column_null :thumbnails, :size, true
change_column_null :thumbnails, :content_type, true
change_column_null :thumbnails, :filename, true
change_column_null :user_account_associations, :user_id, true
change_column_null :user_account_associations, :account_id, true
change_column_null :user_follows, :following_user_id, true
change_column_null :user_follows, :followed_item_id, true
change_column_null :user_notes, :workflow_state, true
change_column_null :user_services, :user_id, true
change_column_null :user_services, :service, true
change_column_null :user_services, :service_user_id, true
change_column_null :user_services, :workflow_state, true
change_column_null :users, :workflow_state, true
change_column_null :web_conferences, :conference_type, true
change_column_null :web_conferences, :title, true
change_column_null :web_conferences, :context_id, true
change_column_null :web_conferences, :context_type, true
change_column_null :web_conferences, :user_id, true
change_column_null :wiki_pages, :workflow_state, true
change_column_null :wiki_pages, :wiki_id, true
change_column_null :zip_file_imports, :context_id, true
change_column_null :zip_file_imports, :context_type, true
change_column_null :zip_file_imports, :workflow_state, true
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2013 - 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 ChangeSubmissionNeedsGradingNotificationTypeToAllSubmissions < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
return unless Shard.current == Shard.default
Notification.where(name: 'Submission Needs Grading').update_all(category: 'All Submissions')
end
def self.down
return unless Shard.current == Shard.default
Notification.where(name: 'Submission Needs Grading').update_all(category: 'Grading')
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 DropTypeFromPseudonyms < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
remove_column :pseudonyms, :type
end
def self.down
add_column :pseudonyms, :type, :string
end
end

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2013 - 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 DropWikiPageComments < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
drop_table :wiki_page_comments
end
def self.down
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 FixOutOfSyncOutcomeAlignments < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
DataFixup::FixOutOfSyncOutcomeAlignments.send_later_if_production_enqueue_args(:run,
:priority => Delayed::LOW_PRIORITY, :max_attempts => 1)
end
def self.down
end
end

View File

@ -1,37 +0,0 @@
#
# Copyright (C) 2013 - 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 AddIndexOnCourseWikiId < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :courses, :wiki_id, algorithm: :concurrently, where: "wiki_id IS NOT NULL"
if connection.adapter_name == 'PostgreSQL'
remove_index :groups, :wiki_id
add_index :groups, :wiki_id, algorithm: :concurrently, where: "wiki_id IS NOT NULL"
end
end
def self.down
remove_index :courses, :wiki_id
if connection.adapter_name == 'PostgreSQL'
remove_index :groups, :wiki_id
add_index :groups, :wiki_id
end
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2013 - 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 AddContentMigrationIndex < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :content_migrations, :context_id, algorithm: :concurrently
end
def self.down
remove_index :content_migrations, :context_id
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2013 - 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 AddIndexOnCccc < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :communication_channels, :confirmation_code, algorithm: :concurrently
end
def self.down
remove_index :communication_channels, :confirmation_code
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 DropEnrollmentsIndexOnIdAndType < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
remove_index :enrollments, [:id, :type]
end
def self.down
add_index :enrollments, [:id, :type]
end
end

View File

@ -1,36 +0,0 @@
#
# Copyright (C) 2013 - 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 RemoveUnneededGistIndexes < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
if is_postgres?
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_wiki_pages_title')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_context_external_tools_name')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_assignments_title')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_quizzes_title')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_discussion_topics_title')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_attachments_display_name')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_context_modules_name')}")
execute("DROP INDEX IF EXISTS #{connection.quote_table_name('index_trgm_content_tags_title')}")
end
end
def self.down
end
end

View File

@ -1,39 +0,0 @@
#
# Copyright (C) 2013 - 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 AddQuizRegradeForeignKeys < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_foreign_key_if_not_exists :quiz_regrades, :users
add_foreign_key_if_not_exists :quiz_regrades, :quizzes
add_foreign_key_if_not_exists :quiz_regrade_runs, :quiz_regrades
add_foreign_key_if_not_exists :quiz_question_regrades, :quiz_regrades
add_foreign_key_if_not_exists :quiz_question_regrades, :quiz_questions
end
def self.down
remove_foreign_key_if_exists :quiz_regrades, :users
remove_foreign_key_if_exists :quiz_regrades, :quizzes
remove_foreign_key_if_exists :quiz_regrade_runs, :quiz_regrades
remove_foreign_key_if_exists :quiz_question_regrades, :quiz_regrades
remove_foreign_key_if_exists :quiz_question_regrades, :quiz_questions
end
end

View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2013 - 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 FixImportedWikiFrontPages < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
DataFixup::FixImportedWikiFrontPages.send_later_if_production_enqueue_args(
:run,
:priority => Delayed::LOW_PRIORITY,
:max_attempts => 1
)
end
def self.down
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 AddWorkflowStateToQuizQuestion < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :quiz_questions, :workflow_state, :string
end
def self.down
remove_column :quiz_questions, :workflow_state
end
end

View File

@ -1,43 +0,0 @@
#
# Copyright (C) 2013 - 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 AddContextModuleProgressionsUniqueIndex < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
ContextModuleProgression.
select([:user_id, :context_module_id]).
group(:user_id, :context_module_id).
preload(:context_module, :user).
where("user_id IS NOT NULL AND context_module_id IS NOT NULL").
having("COUNT(*) > 1").find_each do |cmp|
scope = ContextModuleProgression.
where(user_id: cmp.user_id, context_module_id: cmp.context_module_id)
keeper = scope.order("updated_at DESC").first
scope.where("id<>?", keeper).delete_all
end
add_index :context_module_progressions, [:user_id, :context_module_id], unique: true, name: 'index_cmp_on_user_id_and_module_id', algorithm: :concurrently
remove_index :context_module_progressions, name: 'u_id_module_id'
end
def self.down
remove_index :context_module_progressions, name: 'index_cmp_on_user_id_and_module_id'
add_index :context_module_progressions, [:user_id, :context_module_id], name: 'u_id_module_id', algorithm: :concurrently
end
end

View File

@ -1,47 +0,0 @@
#
# Copyright (C) 2012 - 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 AddForeignKeys7 < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
tag :postdeploy
def self.up
UserAccountAssociation.where("NOT EXISTS (?)", Account.where("account_id=accounts.id")).delete_all
add_foreign_key_if_not_exists :user_account_associations, :accounts, :delay_validation => true
UserAccountAssociation.where("NOT EXISTS (?)", User.where("user_id=users.id")).delete_all
add_foreign_key_if_not_exists :user_account_associations, :users, :delay_validation => true
add_foreign_key_if_not_exists :user_services, :users, :delay_validation => true
add_foreign_key_if_not_exists :web_conferences, :users, :delay_validation => true
add_foreign_key_if_not_exists :wiki_pages, :cloned_items, :delay_validation => true
add_foreign_key_if_not_exists :wiki_pages, :users, :delay_validation => true
add_foreign_key_if_not_exists :wiki_pages, :wikis, :delay_validation => true
add_foreign_key_if_not_exists :zip_file_imports, :attachments, :delay_validation => true
add_foreign_key_if_not_exists :zip_file_imports, :folders, :delay_validation => true
end
def self.down
remove_foreign_key_if_exists :zip_file_imports, :folders
remove_foreign_key_if_exists :zip_file_imports, :attachments
remove_foreign_key_if_exists :wiki_pages, :wikis
remove_foreign_key_if_exists :wiki_pages, :users
remove_foreign_key_if_exists :wiki_pages, :cloned_items
remove_foreign_key_if_exists :web_conferences, :users
remove_foreign_key_if_exists :user_services, :users
remove_foreign_key_if_exists :user_account_associations, :users
remove_foreign_key_if_exists :user_account_associations, :accounts
end
end

View File

@ -1,37 +0,0 @@
#
# Copyright (C) 2013 - 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 ChangeExternalFeedEntryIndexes < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :external_feed_entries, :external_feed_id, algorithm: :concurrently
add_index :external_feed_entries, :uuid, algorithm: :concurrently
add_index :external_feed_entries, :url, algorithm: :concurrently
remove_index :external_feed_entries, name: 'external_feed_id_uuid'
remove_index :external_feed_entries, [:asset_id, :asset_type]
end
def self.down
remove_index :external_feed_entries, :external_feed_id
remove_index :external_feed_entries, :uuid
remove_index :external_feed_entries, :url
add_index :external_feed_entries, [:external_feed_id, :uuid], algorithm: :concurrently, name: 'external_feed_id_uuid'
add_index :external_feed_entries, [:asset_id, :asset_type], algorithm: :concurrently
end
end

View File

@ -1,51 +0,0 @@
#
# Copyright (C) 2013 - 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 AddForeignKeys8 < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :account_notifications, :users, delay_validation: true
add_foreign_key_if_not_exists :account_reports, :users, delay_validation: true
add_foreign_key_if_not_exists :account_users, :users, delay_validation: true
add_foreign_key_if_not_exists :assessment_requests, :users, column: :assessor_id, delay_validation: true
add_foreign_key_if_not_exists :assessment_requests, :users, delay_validation: true
add_foreign_key_if_not_exists :calendar_events, :users, delay_validation: true
add_foreign_key_if_not_exists :collaborators, :users, delay_validation: true
add_foreign_key_if_not_exists :content_exports, :users, delay_validation: true
add_foreign_key_if_not_exists :content_migrations, :users, delay_validation: true
add_foreign_key_if_not_exists :context_module_progressions, :users, delay_validation: true
add_foreign_key_if_not_exists :discussion_entries, :users, column: :editor_id, delay_validation: true
add_foreign_key_if_not_exists :discussion_entries, :users, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :account_notifications, :users
remove_foreign_key_if_exists :account_reports, :users
remove_foreign_key_if_exists :account_users, :users
remove_foreign_key_if_exists :assessment_requests, column: :assessor_id
remove_foreign_key_if_exists :assessment_requests, :users
remove_foreign_key_if_exists :calendar_events, :users
remove_foreign_key_if_exists :collaborators, :users
remove_foreign_key_if_exists :content_exports, :users
remove_foreign_key_if_exists :content_migrations, :users
remove_foreign_key_if_exists :context_module_progressions, :users
remove_foreign_key_if_exists :discussion_entries, column: :editor_id
remove_foreign_key_if_exists :discussion_entries, :users
end
end

View File

@ -1,47 +0,0 @@
#
# Copyright (C) 2013 - 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 AddForeignKeys9 < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :discussion_entry_participants, :users, delay_validation: true
add_foreign_key_if_not_exists :discussion_topic_participants, :users, delay_validation: true
add_foreign_key_if_not_exists :discussion_topics, :users, column: :editor_id, delay_validation: true
add_foreign_key_if_not_exists :discussion_topics, :users, delay_validation: true
add_foreign_key_if_not_exists :enrollments, :users, column: :associated_user_id, delay_validation: true
add_foreign_key_if_not_exists :enrollments, :users, delay_validation: true
add_foreign_key_if_not_exists :external_feed_entries, :users, delay_validation: true
add_foreign_key_if_not_exists :external_feeds, :users, delay_validation: true
add_foreign_key_if_not_exists :grading_standards, :users, delay_validation: true
add_foreign_key_if_not_exists :group_memberships, :users, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :discussion_entry_participants, :users
remove_foreign_key_if_exists :discussion_topic_participants, :users
remove_foreign_key_if_exists :discussion_topics, column: :editor_id
remove_foreign_key_if_exists :discussion_topics, :users
remove_foreign_key_if_exists :enrollments, column: :associated_user_id
remove_foreign_key_if_exists :enrollments, :users
remove_foreign_key_if_exists :external_feed_entries, :users
remove_foreign_key_if_exists :external_feeds, :users
remove_foreign_key_if_exists :grading_standards, :users
remove_foreign_key_if_exists :group_memberships, :users
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 AddGroupToBatchConversations < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :conversation_batches, :group, :boolean
end
def self.down
remove_column :conversation_batches, :group
end
end

View File

@ -1,50 +0,0 @@
#
# Copyright (C) 2013 - 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 AddForeignKeys10 < ActiveRecord::Migration[4.2]
# this used to be post deploy, but now we need to modify a constraint in a
# predeploy so a new database will have the contrainte before it is attempted
# to be modified.
tag :predeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :learning_outcome_results, :users, delay_validation: true
add_foreign_key_if_not_exists :media_objects, :users, delay_validation: true
add_foreign_key_if_not_exists :page_comments, :users, delay_validation: true
add_foreign_key_if_not_exists :page_views, :users, column: :real_user_id, delay_validation: true
add_foreign_key_if_not_exists :page_views, :users, delay_validation: true
add_foreign_key_if_not_exists :pseudonyms, :users, delay_validation: true
add_foreign_key_if_not_exists :quiz_submissions, :users, delay_validation: true
add_foreign_key_if_not_exists :rubric_assessments, :users, column: :assessor_id, delay_validation: true
add_foreign_key_if_not_exists :rubric_assessments, :users, delay_validation: true
add_foreign_key_if_not_exists :rubrics, :users, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :learning_outcome_results, :users
remove_foreign_key_if_exists :media_objects, :users
remove_foreign_key_if_exists :page_comments, :users
remove_foreign_key_if_exists :page_views, column: :real_user_id
remove_foreign_key_if_exists :page_views, :users
remove_foreign_key_if_exists :pseudonyms, :users
remove_foreign_key_if_exists :quiz_submissions, :users
remove_foreign_key_if_exists :rubric_assessments, column: :assessor_id
remove_foreign_key_if_exists :rubric_assessments, :users
remove_foreign_key_if_exists :rubrics, :users
end
end

View File

@ -1,56 +0,0 @@
#
# Copyright (C) 2013 - 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 AddForeignKeys11 < ActiveRecord::Migration[4.2]
# this used to be post deploy, but now we need to modify a constraint in a
# predeploy so a new database will have the contrainte before it is attempted
# to be modified.
tag :predeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :submission_comment_participants, :users, delay_validation: true
add_foreign_key_if_not_exists :submission_comments, :users, column: :author_id, delay_validation: true
add_foreign_key_if_not_exists :submission_comments, :users, column: :recipient_id, delay_validation: true
add_foreign_key_if_not_exists :submissions, :users, delay_validation: true
add_foreign_key_if_not_exists :user_notes, :users, column: :created_by_id, delay_validation: true
add_foreign_key_if_not_exists :user_notes, :users, delay_validation: true
add_foreign_key_if_not_exists :web_conference_participants, :users, delay_validation: true
add_foreign_key_if_not_exists :web_conferences, :users, delay_validation: true
add_foreign_key_if_not_exists :wiki_pages, :users, delay_validation: true
add_foreign_key_if_not_exists :conversation_messages, :conversations, delay_validation: true
add_foreign_key_if_not_exists :conversation_message_participants, :conversation_messages, delay_validation: true
add_foreign_key_if_not_exists :conversation_batches, :conversation_messages, column: :root_conversation_message_id, delay_validation: true
add_foreign_key_if_not_exists :conversation_batches, :users, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :submission_comment_participants, :users
remove_foreign_key_if_exists :submission_comments, column: :author_id
remove_foreign_key_if_exists :submission_comments, column: :recipient_id
remove_foreign_key_if_exists :submissions, :users
remove_foreign_key_if_exists :user_notes, column: :created_by_id
remove_foreign_key_if_exists :user_notes, :users
remove_foreign_key_if_exists :web_conference_participants, :users
remove_foreign_key_if_exists :web_conferences, :users
remove_foreign_key_if_exists :wiki_pages, :users
remove_foreign_key_if_exists :conversation_messages, :conversations
remove_foreign_key_if_exists :conversation_message_participants, :conversation_messages
remove_foreign_key_if_exists :conversation_batches, column: :root_conversation_message_id
remove_foreign_key_if_exists :conversation_batches, :users
end
end

View File

@ -1,34 +0,0 @@
#
# Copyright (C) 2013 - 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 AddCassandraPageViewsRemoteIp < ActiveRecord::Migration[4.2]
tag :predeploy
include Canvas::Cassandra::Migration
def self.cassandra_cluster
'page_views'
end
def self.up
cassandra.execute %{ ALTER TABLE page_views ADD remote_ip text; }
end
def self.down
cassandra.execute %{ ALTER TABLE page_views DROP remote_ip; }
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 AddPageViewsRemoteIp < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :page_views, :remote_ip, :string
end
def self.down
remove_column :page_views, :remote_ip
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 DropDownstreamModulesFromContextModules < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
remove_column :context_modules, :downstream_modules
end
def self.down
add_column :context_modules, :downstream_modules, :text
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 AddCompletionEventsToContextModules < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :context_modules, :completion_events, :text
end
def self.down
add_column :context_modules, :completion_events
end
end

View File

@ -1,25 +0,0 @@
#
# Copyright (C) 2013 - 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 PopulateSubmissionVersions < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
DataFixup::PopulateSubmissionVersions.send_later_if_production_enqueue_args(:run,
:priority => Delayed::LOWER_PRIORITY, :max_attempts => 1, :n_strand => 'long_datafixups')
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 RemoveOrphanedContextModuleProgressions < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
DataFixup::RemoveOrphanedContextModuleProgressions.send_later_if_production_enqueue_args(
:run,
:priority => Delayed::LOW_PRIORITY,
:max_attempts => 1
)
end
end

View File

@ -1,33 +0,0 @@
#
# Copyright (C) 2013 - 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 AddPushColumns < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :developer_keys, :sns_arn, :string
add_column :communication_channels, :access_token_id, :integer, limit: 8
add_column :communication_channels, :internal_path, :string
add_foreign_key :communication_channels, :access_tokens
end
def self.down
remove_column :developer_keys, :sns_arn
remove_column :communication_channels, :access_token_id
remove_column :communication_channels, :internal_path
end
end

View File

@ -1,37 +0,0 @@
#
# Copyright (C) 2013 - 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 CreateFeatureFlags < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
create_table :feature_flags do |t|
t.integer :context_id, limit: 8, null: false
t.string :context_type, null: false
t.string :feature, null: false
t.string :state, default: 'allowed', null: false
t.integer :locking_account_id, limit: 8
t.timestamps null: true
end
add_index :feature_flags, [:context_id, :context_type, :feature], unique: true,
name: 'index_feature_flags_on_context_and_feature'
end
def self.down
drop_table :feature_flags
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2013 - 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 AddScoreVisibilityToQuizzes < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :quizzes, :show_correct_answers_at, :datetime
add_column :quizzes, :hide_correct_answers_at, :datetime
end
def self.down
remove_column :quizzes, :hide_correct_answers_at
remove_column :quizzes, :show_correct_answers_at
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2013 - 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 AddStaleScribdIndexToAttachments < ActiveRecord::Migration[4.2]
tag :predeploy
disable_ddl_transaction!
def self.up
add_index :attachments, [:last_inline_view, :created_at], where: "scribd_doc IS NOT NULL", algorithm: :concurrently
end
def self.down
remove_index :attachments, [:last_inline_view, :created_at]
end
end

View File

@ -1,43 +0,0 @@
#
# Copyright (C) 2013 - 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 RemoveScribdAccount < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
drop_table :scribd_accounts
remove_column :attachments, :scribd_account_id
remove_column :attachments, :scribd_user
end
def self.down
create_table "scribd_accounts", :force => true do |t|
t.integer "scribdable_id", :limit => 8
t.string "scribdable_type"
t.string "uuid"
t.string "workflow_state"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "scribd_accounts", ["scribdable_id", "scribdable_type"], :name => "index_scribd_accounts_on_scribdable_id_and_scribdable_type"
add_column :attachments, :scribd_account_id, :integer, :limit => 8
add_column :attachments, :scribd_user, :string
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2013 - 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 UndeleteSomeOutcomeAlignments < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
DataFixup::UndeleteSomeOutcomeAlignments.send_later_if_production_enqueue_args(:run,
:priority => Delayed::LOW_PRIORITY, :max_attempts => 1)
end
def self.down
end
end

View File

@ -1,77 +0,0 @@
#
# Copyright (C) 2013 - 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 AddCassandraGradeChangeAuditorTables < ActiveRecord::Migration[4.2]
tag :predeploy
include Canvas::Cassandra::Migration
def self.cassandra_cluster
'auditors'
end
def self.indexes
%w(
grade_changes_by_assignment
grade_changes_by_course
grade_changes_by_root_account_student
grade_changes_by_root_account_grader
)
end
def self.up
compression_params = cassandra.db.use_cql3? ?
"WITH compression = { 'sstable_compression' : 'DeflateCompressor' }" :
"WITH compression_parameters:sstable_compression='DeflateCompressor'"
cassandra.execute %{
CREATE TABLE grade_changes (
id text PRIMARY KEY,
created_at timestamp,
request_id text,
account_id bigint,
submission_id bigint,
version_number int,
grader_id bigint,
student_id bigint,
assignment_id bigint,
context_id bigint,
context_type text,
event_type text,
grade_before text,
grade_after text
) #{compression_params}}
indexes.each do |index_name|
cassandra.execute %{
CREATE TABLE #{index_name} (
key text,
ordered_id text,
id text,
PRIMARY KEY (key, ordered_id)
) #{compression_params}}
end
end
def self.down
indexes.each do |index_name|
cassandra.execute %{DROP TABLE #{index_name};}
end
cassandra.execute %{DROP TABLE grade_changes;}
end
end

View File

@ -1,53 +0,0 @@
#
# Copyright (C) 2013 - 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 AddAssociationToLearningOutcomeResultsIndex < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
rename_index :learning_outcome_results, 'index_learning_outcome_results_association', 'temp_index_learning_outcome'
LearningOutcomeResult.
select("user_id, content_tag_id, association_id, association_type,
associated_asset_id, associated_asset_type").
group("user_id, content_tag_id, association_id, association_type,
associated_asset_id, associated_asset_type").
having("COUNT(*) > 1").find_each do |lor|
scope = LearningOutcomeResult.
where(user_id: lor.user_id,
content_tag_id: lor.content_tag_id,
associated_asset_id: lor.associated_asset_id,
association_id: lor.association_id,
association_type: lor.association_type,
associated_asset_type: lor.associated_asset_type)
keeper = scope.order("updated_at DESC").first
scope.where("id<>?", keeper).delete_all
end
add_index :learning_outcome_results,
[:user_id, :content_tag_id, :association_id, :association_type, :associated_asset_id, :associated_asset_type],
unique: true,
name: "index_learning_outcome_results_association",
algorithm: :concurrently
remove_index :learning_outcome_results, name: "temp_index_learning_outcome"
end
def self.down
# Not possible to reliably revert to the old index, which was only on
# user_id and content_tag_id, and associated_asset
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
module DataFixup::FixImportedWikiFrontPages
# some Wiki objects are getting has_no_front_page set to true, even when there should be a front page
def self.potentially_broken_wikis
Wiki.where(:has_no_front_page => true)
end
def self.run
self.potentially_broken_wikis.find_in_batches do |wikis|
Wiki.where(:id => wikis).update_all(:has_no_front_page => nil)
end
end
end

View File

@ -1,96 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
module DataFixup::FixOutOfSyncOutcomeAlignments
def self.run
# Active alignments to deleted rubrics
scope = ContentTag.joins("
INNER JOIN #{Rubric.quoted_table_name} r
ON content_tags.content_id = r.id
AND content_tags.content_type = 'Rubric'
").select("content_tags.*")
scope = scope.where("
content_tags.tag_type = 'learning_outcome'
AND content_tags.workflow_state = 'active'
AND r.workflow_state = 'deleted'
")
scope.find_each do |ct|
ct.destroy
end
# Active alignments to rubrics that should no longer be aligned
scope = ContentTag.joins("
INNER JOIN #{Rubric.quoted_table_name} r
ON content_tags.content_id = r.id
AND content_tags.content_type = 'Rubric'
").select("content_tags.*")
scope = scope.where("
content_tags.tag_type = 'learning_outcome'
AND content_tags.workflow_state = 'active'
AND r.workflow_state = 'active'
AND NOT r.data LIKE '%learning_outcome_id: ' || content_tags.learning_outcome_id || '%'
")
scope.find_each do |ct|
ct.destroy
end
# Active alignments to assignments without rubrics
scope = ContentTag.joins("
INNER JOIN #{Assignment.quoted_table_name} a
ON content_tags.content_id = a.id
AND content_tags.content_type = 'Assignment'
LEFT OUTER JOIN #{RubricAssociation.quoted_table_name} ra
ON ra.association_id = a.id
AND ra.association_type = 'Assignment'
").select("content_tags.*")
scope = scope.where("
content_tags.tag_type = 'learning_outcome'
AND content_tags.workflow_state = 'active'
AND ra.id IS NULL
")
scope.find_each do |ct|
ct.destroy
end
# Active alignments to assignments with rubrics
# that don't have a matching alignment
scope = ContentTag.joins("
INNER JOIN #{Assignment.quoted_table_name} a
ON content_tags.content_id = a.id
AND content_tags.content_type = 'Assignment'
INNER JOIN #{RubricAssociation.quoted_table_name} ra
ON ra.association_id = a.id
AND ra.association_type = 'Assignment'
INNER JOIN #{Rubric.quoted_table_name} r
ON ra.rubric_id = r.id
LEFT OUTER JOIN #{ContentTag.quoted_table_name} ct2
ON ct2.content_id = r.id
AND ct2.content_type = 'Rubric'
AND ct2.tag_type = 'learning_outcome'
AND ct2.workflow_state = 'active'
AND ct2.learning_outcome_id = content_tags.learning_outcome_id
").select("content_tags.*")
scope = scope.where("
content_tags.tag_type = 'learning_outcome'
AND content_tags.workflow_state = 'active'
AND ct2.id IS NULL
")
scope.find_each do |ct|
ct.destroy
end
end
end

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2011 - 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/>.
#
module DataFixup::PopulateSubmissionVersions
def self.run
Version.where(:versionable_type => 'Submission').
where("NOT EXISTS (?)", SubmissionVersion.where("version_id=versions.id")).
find_in_batches do |versions|
SubmissionVersion.index_versions(versions, ignore_errors: true)
end
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
module DataFixup::RemoveOrphanedContextModuleProgressions
def self.run
scope = ContextModuleProgression.
joins(:context_module).
where(context_modules: { context_type: 'Course' }).
where("requirements_met=? OR requirements_met IS NULL", [].to_yaml).
where("NOT EXISTS (?)", Enrollment.where("course_id=context_id AND enrollments.user_id=context_module_progressions.user_id"))
scope.find_ids_in_ranges do |first, last|
ContextModuleProgression.where(id: first..last).delete_all
end
end
end

View File

@ -1,78 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
module DataFixup::UndeleteSomeOutcomeAlignments
def self.run
occurred = Time.zone.parse("2013-09-14 00:00:00 UTC")
rubric_ids = []
# See lib/data_fixup/fix_out_of_sync_outcome_alignments, the second block
# with the comment "Active alignments to rubrics that should no longer be
# aligned". When the data was a HashWithIndifferentAccess instead of just
# a Hash, it didn't have the comma in front of learning_outcome_id. This
# brings those content tags back.
scope = ContentTag.joins("
INNER JOIN #{Rubric.quoted_table_name} r
ON content_tags.content_id = r.id
AND content_tags.content_type = 'Rubric'
").select("content_tags.*")
scope = scope.where("
content_tags.tag_type = 'learning_outcome'
AND content_tags.workflow_state = 'deleted'
AND content_tags.updated_at > ?
AND r.workflow_state = 'active'
AND NOT r.data LIKE '%:learning_outcome_id: ' || content_tags.learning_outcome_id || '%'
AND r.data LIKE '%learning_outcome_id: ' || content_tags.learning_outcome_id || '%'
", occurred)
scope.find_each do |ct|
ct.workflow_state = 'active'
ct.save!
rubric_ids << ct.content_id
end
# The fourth block in that same fixup then found outcomes that should no
# longer be aligned to assignments, so we need to bring those back as well.
rubric_ids.each_slice(1000) do |rids|
scope = ContentTag.joins("
INNER JOIN #{Assignment.quoted_table_name} a
ON content_tags.content_id = a.id
AND content_tags.content_type = 'Assignment'
INNER JOIN #{RubricAssociation.quoted_table_name} ra
ON ra.association_id = a.id
AND ra.association_type = 'Assignment'
INNER JOIN #{Rubric.quoted_table_name} r
ON ra.rubric_id = r.id
INNER JOIN #{ContentTag.quoted_table_name} ct2
ON ct2.content_id = r.id
AND ct2.content_type = 'Rubric'
AND ct2.tag_type = 'learning_outcome'
AND ct2.workflow_state = 'active'
AND ct2.learning_outcome_id = content_tags.learning_outcome_id
").select("content_tags.*")
scope = scope.where("
content_tags.tag_type = 'learning_outcome'
AND content_tags.workflow_state = 'deleted'
AND ct2.content_id IN (?)
AND content_tags.updated_at > ?
", rids, occurred)
scope.find_each do |ct|
ct.workflow_state = 'active'
ct.save!
end
end
end
end

View File

@ -1,84 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
describe DataFixup::FixOutOfSyncOutcomeAlignments do
before do
course_with_teacher(:active_all => true)
outcome_with_rubric
@rubric_association_object = @course.assignments.create!(:title => 'blah')
@rubric_association = @rubric.rubric_associations.create!({
:association_object => @rubric_association_object,
:context => @course,
:purpose => 'grading'
})
end
it "should not delete active alignments" do
align1 = @rubric_association_object.learning_outcome_alignments.first
align2 = @rubric.learning_outcome_alignments.first
expect(align1.reload).not_to be_deleted
expect(align2.reload).not_to be_deleted
DataFixup::FixOutOfSyncOutcomeAlignments.run
expect(align1.reload).not_to be_deleted
expect(align2.reload).not_to be_deleted
end
it "should delete alignments to deleted rubrics" do
align = @rubric.learning_outcome_alignments.first
Rubric.where(:id => @rubric.id).update_all(:workflow_state => 'deleted')
expect(align.reload).not_to be_deleted
DataFixup::FixOutOfSyncOutcomeAlignments.run
expect(align.reload).to be_deleted
end
it "should delete alignments to rubrics that no longer should be aligned" do
align = @rubric.learning_outcome_alignments.first
data = @rubric.data
data.first.delete(:learning_outcome_id)
Rubric.where(:id => @rubric.id).update_all(:data => data.to_yaml)
expect(align.reload).not_to be_deleted
DataFixup::FixOutOfSyncOutcomeAlignments.run
expect(align.reload).to be_deleted
end
it "should delete alignments to assignments without rubrics" do
align = @rubric_association_object.learning_outcome_alignments.first
RubricAssociation.where(:rubric_id => @rubric.id).delete_all
expect(align.reload).not_to be_deleted
DataFixup::FixOutOfSyncOutcomeAlignments.run
expect(align.reload).to be_deleted
end
it "should delete alignments to assignments with rubrics without matching alignments" do
align = @rubric_association_object.learning_outcome_alignments.first
lo = LearningOutcome.create!(short_description: 's')
@rubric.learning_outcome_alignments.update_all(:learning_outcome_id => lo.id)
expect(align.reload).not_to be_deleted
DataFixup::FixOutOfSyncOutcomeAlignments.run
expect(align.reload).to be_deleted
end
end

View File

@ -1,59 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
require 'lib/data_fixup/populate_submission_versions.rb'
describe DataFixup::PopulateSubmissionVersions do
it "should not migrate a non-submission version" do
wiki_page_model
version = Version.create(:versionable => @page, :yaml => @page.attributes.to_yaml)
expect{
DataFixup::PopulateSubmissionVersions.run
}.not_to change(SubmissionVersion, :count)
end
it "should not migrate a submission version already having a submission_version" do
course_with_student
@course.assignments.create!
expect{
DataFixup::PopulateSubmissionVersions.run
}.not_to change(SubmissionVersion, :count)
end
it "should migrate all submission version rows without submission_versions" do
n = 5
course_with_student
submission = @user.submissions.find_by(assignment: @course.assignments.create!)
n.times { |x| Version.create(:versionable => submission, :yaml => submission.attributes.to_yaml) }
expect{
DataFixup::PopulateSubmissionVersions.run
}.to change(SubmissionVersion, :count).by(n)
end
it "should skip submission version rows without a corresponding submission object" do
course_with_student
submission = @user.submissions.find_by(assignment: @course.assignments.create!)
Version.create(:versionable => submission, :yaml => submission.attributes.to_yaml)
submission.delete
expect{
DataFixup::PopulateSubmissionVersions.run
}.not_to change(SubmissionVersion, :count)
end
end

View File

@ -1,36 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
describe DataFixup::RemoveOrphanedContextModuleProgressions do
it "should work" do
c1 = Course.create!
c2 = Course.create!
cm1 = c1.context_modules.create!
cm2 = c2.context_modules.create!
u = User.create!
c1.enroll_student(u)
cmp1 = cm1.context_module_progressions.create!(user: u)
cmp2 = cm2.context_module_progressions.create!(user: u)
DataFixup::RemoveOrphanedContextModuleProgressions.run
cmp1.reload
expect { cmp2.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end

View File

@ -1,58 +0,0 @@
#
# Copyright (C) 2013 - 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/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
describe DataFixup::UndeleteSomeOutcomeAlignments do
before do
course_with_teacher(:active_all => true)
outcome_with_rubric
@rubric_association_object = @course.assignments.create!(:title => 'blah')
@rubric_association = @rubric.rubric_associations.create!({
:association_object => @rubric_association_object,
:context => @course,
:purpose => 'grading'
})
end
it "should undelete tags on rubrics that should still exist, and their corresponding assignments" do
align = @rubric.learning_outcome_alignments.first
align2 = @rubric_association_object.learning_outcome_alignments.first
data = @rubric.data.map{|h| h.with_indifferent_access}
Rubric.where(:id => @rubric.id).update_all(:data => data.to_yaml)
ContentTag.where(:id => [align, align2]).update_all(:workflow_state => 'deleted')
expect(align.reload).to be_deleted
expect(align2.reload).to be_deleted
DataFixup::UndeleteSomeOutcomeAlignments.run
expect(align.reload).not_to be_deleted
expect(align2.reload).not_to be_deleted
end
it "should not undelete assignments tags that aren't linked to rubrics already undeleted" do
align = @rubric_association_object.learning_outcome_alignments.first
ContentTag.where(:id => align).update_all(:workflow_state => 'deleted')
expect(align.reload).to be_deleted
DataFixup::UndeleteSomeOutcomeAlignments.run
expect(align.reload).to be_deleted
end
end