squash old migrations, p4

Change-Id: If5b2e35de5d71b6da6056d1ec6cb8896319afeb6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/223092
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Simon Williams 2020-01-13 16:00:40 -06:00
parent 63921c7a3b
commit e384ce7f68
28 changed files with 89 additions and 999 deletions

View File

@ -28,7 +28,7 @@ class ValidateMigrationIntegrity < ActiveRecord::Migration[4.2]
def self.up
initial_migration_version = "20101210192618"
last_squashed_migration_version = "20110817173455"
last_squashed_migration_version = "20110925050308"
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?

View File

@ -34,6 +34,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.datetime "updated_at"
t.integer "enrollment_term_id", :limit => 8
t.string "workflow_state"
t.text "stuck_sis_fields"
end
add_index "abstract_courses", ["root_account_id", "sis_source_id"], :name => "index_abstract_courses_on_root_account_id_and_sis_source_id"
@ -128,7 +129,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "current_sis_batch_id"
t.integer "root_account_id", :limit => 8
t.string "last_successful_sis_batch_id"
t.boolean "moved_in_account_structure", :default => true
t.string "membership_types"
t.boolean "require_authorization_code"
t.string "default_time_zone"
@ -149,6 +149,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "sis_name"
t.string "uuid"
t.string "default_locale"
t.text "stuck_sis_fields"
end
add_index "accounts", ["id", "type"], :name => "index_accounts_on_id_and_type"
@ -341,6 +342,8 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.boolean "turnitin_enabled"
t.string "allowed_extensions"
t.integer "needs_grading_count", :default => 0
t.text "turnitin_settings"
t.boolean "muted", :default => false
end
add_index "assignments", ["assignment_group_id"], :name => "index_assignments_on_assignment_group_id"
@ -575,6 +578,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "content_tags", ["context_id", "context_type"], :name => "index_content_tags_on_context_id_and_context_type"
add_index "content_tags", ["context_module_id"], :name => "index_content_tags_on_context_module_id"
add_index "content_tags", ["workflow_state"], :name => "index_content_tags_on_workflow_state"
add_index :content_tags, [ :associated_asset_id, :associated_asset_type ], :name => 'index_content_tags_on_associated_asset'
create_table :context_external_tools do |t|
t.integer :context_id, :limit => 8
@ -587,10 +591,19 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.text :description
t.text :settings
t.string :workflow_state
t.timestamps null: true
t.string :migration_id
t.boolean :has_user_navigation
t.boolean :has_course_navigation
t.boolean :has_account_navigation
t.boolean :has_resource_selection
t.boolean :has_editor_button
end
add_index :context_external_tools, [:context_id, :context_type, :has_user_navigation], :name => "external_tools_user_navigation"
add_index :context_external_tools, [:context_id, :context_type, :has_course_navigation], :name => "external_tools_course_navigation"
add_index :context_external_tools, [:context_id, :context_type, :has_account_navigation], :name => "external_tools_account_navigation"
add_index :context_external_tools, [:context_id, :context_type, :has_resource_selection], :name => "external_tools_resource_selection"
add_index :context_external_tools, [:context_id, :context_type, :has_editor_button], :name => "external_tools_editor_button"
create_table "context_message_participants", :force => true do |t|
t.integer "user_id", :limit => 8
@ -694,6 +707,8 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "media_comment_id"
t.string "media_comment_type"
t.integer "context_message_id", :limit => 8
t.integer "context_id", :limit => 8
t.string "context_type"
end
add_index "conversation_messages", ["conversation_id", "created_at"]
@ -723,6 +738,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "workflow_state"
t.string "import_type"
t.integer "progress"
t.text "parameters"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -752,6 +768,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.integer "account_id", :limit => 8
t.integer "nonxlist_course_id", :limit => 8
t.boolean "sticky_xlist"
t.text "stuck_sis_fields"
end
add_index "course_sections", ["course_id"], :name => "index_course_sections_on_course_id"
@ -761,7 +778,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
create_table "courses", :force => true do |t|
t.string "name"
t.string "section"
t.integer "account_id", :limit => 8
t.string "group_weighting_scheme"
t.integer "old_account_id", :limit => 8
@ -779,7 +795,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "hashtag"
t.boolean "show_public_context_messages"
t.text "syllabus_body", :limit => 16777215
t.text "hidden_tabs"
t.boolean "allow_student_forum_attachments", :default => false
t.string "default_wiki_editing_roles"
t.integer "wiki_id", :limit => 8
@ -790,7 +805,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.integer "root_account_id", :limit => 8
t.integer "enrollment_term_id", :limit => 8
t.string "sis_source_id"
t.boolean "moved_in_account_structure", :default => true
t.string "sis_batch_id"
t.boolean "show_all_discussion_entries"
t.boolean "open_enrollment"
@ -807,16 +821,18 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.integer "template_course_id", :limit => 8
t.string "locale"
t.text "settings"
t.integer "replacement_course_id", :limit => 8
t.text "stuck_sis_fields"
end
add_index "courses", ["abstract_course_id"], :name => "index_courses_on_abstract_course_id"
add_index "courses", ["account_id"], :name => "index_courses_on_account_id"
add_index "courses", ["enrollment_term_id"], :name => "index_courses_on_enrollment_term_id"
add_index "courses", ["grading_standard_id"], :name => "index_courses_on_grading_standard_id"
add_index "courses", ["moved_in_account_structure", "updated_at"], :name => "index_courses_on_moved_in_account_structure_and_updated_at"
add_index "courses", ["root_account_id"], :name => "index_courses_on_root_account_id"
add_index "courses", ["wiki_id"], :name => "index_courses_on_wiki_id"
add_index :courses, [:template_course_id]
add_index :courses, :uuid
create_table "custom_field_values", :force => true do |t|
t.integer "custom_field_id", :limit => 8
@ -901,6 +917,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "discussion_entries", ["attachment_id"], :name => "index_discussion_entries_on_attachment_id"
add_index "discussion_entries", ["discussion_topic_id"], :name => "index_discussion_entries_on_discussion_topic_id"
add_index "discussion_entries", ["user_id"], :name => "index_discussion_entries_on_user_id"
add_index :discussion_entries, :parent_id
create_table "discussion_topics", :force => true do |t|
t.string "title"
@ -965,12 +982,12 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.datetime "end_at"
t.boolean "accepting_enrollments"
t.boolean "can_manually_enroll"
t.text "sis_data"
t.datetime "created_at"
t.datetime "updated_at"
t.string "sis_name"
t.string "workflow_state", :default => "active"
t.boolean "ignore_term_date_restrictions"
t.text "stuck_sis_fields"
end
add_index "enrollment_terms", ["root_account_id", "sis_source_id"], :name => "index_enrollment_terms_on_root_account_id_and_sis_source_id"
@ -1130,7 +1147,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
create_table "folders", :force => true do |t|
t.string "name"
t.string "full_name"
t.text "full_name"
t.integer "context_id", :limit => 8
t.string "context_type"
t.integer "parent_folder_id", :limit => 8
@ -1172,6 +1189,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "context_code"
t.string "workflow_state"
t.string "migration_id"
t.integer "version"
end
add_index "grading_standards", ["context_code"], :name => "index_grading_standards_on_context_code"
@ -1220,6 +1238,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "sis_source_id"
t.string "sis_name"
t.string "sis_batch_id"
t.text "stuck_sis_fields"
end
add_index "groups", ["account_id"], :name => "index_groups_on_account_id"
@ -1311,30 +1330,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.datetime "updated_at"
t.string "migration_id"
end
create_table "mailboxes", :force => true do |t|
t.string "name"
t.string "purpose", :default => "broadcast"
t.string "handle"
t.string "content_parser"
t.string "workflow_state"
t.string "mailboxable_entity_type"
t.integer "mailboxable_entity_id", :limit => 8
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "mailboxes", ["handle"], :name => "index_mailboxes_on_handle"
add_index "mailboxes", ["mailboxable_entity_id", "mailboxable_entity_type"], :name => "me_id_and_me_type"
create_table "mailboxes_pseudonyms", :force => true do |t|
t.integer "mailbox_id", :limit => 8
t.integer "pseudonym_id", :limit => 8
t.string "workflow_state"
t.boolean "originating_party"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index :learning_outcomes, [ :context_id, :context_type ]
create_table "media_objects", :force => true do |t|
t.integer "user_id", :limit => 8
@ -1546,7 +1542,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "sis_source_id"
t.string "sis_batch_id"
t.string "sis_user_id"
t.text "sis_update_data"
t.string "sis_ssha"
t.integer "communication_channel_id", :limit => 8
t.string "login_path_to_ignore"
@ -1691,7 +1686,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "context_type"
t.datetime "created_at"
t.datetime "updated_at"
t.string "context_code"
end
add_index "role_overrides", ["context_id", "context_type"], :name => "index_role_overrides_on_context_id_and_context_type"
@ -1920,6 +1914,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.text "cached_attachments"
t.boolean "anonymous"
t.boolean "teacher_only_comment", :default => false
t.boolean "hidden", :default => false
end
add_index "submission_comments", ["assessment_request_id"], :name => "index_submission_comments_on_assessment_request_id"
@ -2036,7 +2031,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
create_table "users", :force => true do |t|
t.string "name"
t.string "type"
t.string "sortable_name"
t.string "workflow_state"
t.integer "merge_to"
@ -2059,7 +2053,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "creation_unique_id"
t.string "creation_sis_batch_id"
t.string "creation_email"
t.boolean "moved_in_account_structure", :default => true
t.integer "unread_inbox_items_count"
t.integer "reminder_time_for_due_dates", :default => 172800
t.integer "reminder_time_for_grading", :default => 0
@ -2074,12 +2067,11 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "locale"
t.string "browser_locale"
t.integer "unread_conversations_count", :default => 0
t.text "stuck_sis_fields"
end
add_index "users", ["avatar_state", "avatar_image_updated_at"], :name => "index_users_on_avatar_state_and_avatar_image_updated_at"
add_index "users", ["creation_unique_id", "creation_sis_batch_id"], :name => "users_sis_creation"
add_index "users", ["id", "type"], :name => "index_users_on_id_and_type"
add_index "users", ["moved_in_account_structure"], :name => "index_users_on_moved_in_account_structure"
add_index "users", ["sortable_name"], :name => "index_users_on_sortable_name"
add_index "users", ["uuid"], :name => "index_users_on_uuid"
@ -2252,6 +2244,36 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
SQL_ACTIONS
end
end
create_trigger("submission_comments_after_insert_row_tr", :generated => true, :compatibility => 1).
on("submission_comments").
after(:insert) do
<<-SQL_ACTIONS
UPDATE submissions
SET has_admin_comment=EXISTS(
SELECT 1 FROM submission_comments AS sc, assignments AS a, courses AS c, enrollments AS e
WHERE sc.submission_id = submissions.id AND a.id = submissions.assignment_id
AND c.id = a.context_id AND a.context_type = 'Course' AND e.course_id = c.id
AND e.user_id = sc.author_id AND e.workflow_state = 'active'
AND e.type IN ('TeacherEnrollment', 'TaEnrollment'))
WHERE id = NEW.submission_id;
SQL_ACTIONS
end
create_trigger("submission_comments_after_delete_row_tr", :generated => true, :compatibility => 1).
on("submission_comments").
after(:delete) do
<<-SQL_ACTIONS
UPDATE submissions
SET has_admin_comment=EXISTS(
SELECT 1 FROM submission_comments AS sc, assignments AS a, courses AS c, enrollments AS e
WHERE sc.submission_id = submissions.id AND a.id = submissions.assignment_id
AND c.id = a.context_id AND a.context_type = 'Course' AND e.course_id = c.id
AND e.user_id = sc.author_id AND e.workflow_state = 'active'
AND e.type IN ('TeacherEnrollment', 'TaEnrollment'))
WHERE id = OLD.submission_id;
SQL_ACTIONS
end
end
def self.down

View File

@ -50,12 +50,39 @@ class CreateDelayedJobs < ActiveRecord::Migration[4.2]
table.string :tag
table.integer :max_attempts
table.string :strand
table.boolean :next_in_strand, :default => true, :null => false
table.integer :shard_id, :limit => 8
end
connection.execute("CREATE INDEX get_delayed_jobs_index ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} (priority, run_at) WHERE locked_at IS NULL AND queue = 'canvas_queue' AND next_in_strand = 't'")
add_index :delayed_jobs, [:tag]
add_index :delayed_jobs, %w(run_at queue locked_at strand priority), :name => 'index_delayed_jobs_for_get_next'
add_index :delayed_jobs, %w(strand id), :name => 'index_delayed_jobs_on_strand'
# create the insert trigger
execute(<<-CODE)
CREATE FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')} () RETURNS trigger AS $$
BEGIN
LOCK delayed_jobs IN SHARE ROW EXCLUSIVE MODE;
IF (SELECT 1 FROM delayed_jobs WHERE strand = NEW.strand LIMIT 1) = 1 THEN
NEW.next_in_strand := 'f';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CODE
execute("CREATE TRIGGER delayed_jobs_before_insert_row_tr BEFORE INSERT ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} FOR EACH ROW WHEN (NEW.strand IS NOT NULL) EXECUTE PROCEDURE #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')}()")
#
# create the delete trigger
execute(<<-CODE)
CREATE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
BEGIN
UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1);
RETURN OLD;
END;
$$ LANGUAGE plpgsql;
CODE
execute("CREATE TRIGGER delayed_jobs_after_delete_row_tr AFTER DELETE ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} FOR EACH ROW WHEN (OLD.strand IS NOT NULL AND OLD.next_in_strand = 't') EXECUTE PROCEDURE #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')}()")
create_table :failed_jobs do |t|
t.integer "priority", :default => 0
t.integer "attempts", :default => 0

View File

@ -1,28 +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/>.
class IncreaseFolderNameSize < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
change_column :folders, :full_name, :text
end
def self.down
change_column :folders, :full_name, :string
end
end

View File

@ -1,62 +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/>.
# This migration was auto-generated via `rake db:generate_trigger_migration'.
# While you can edit this file, any changes you make to the definitions here
# will be undone by the next auto-generated trigger migration.
class CreateTriggersSubmissionCommentsInsertAndSubmissionCommentsDelete < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
create_trigger("submission_comments_after_insert_row_tr", :generated => true, :compatibility => 1).
on("submission_comments").
after(:insert) do
<<-SQL_ACTIONS
UPDATE submissions
SET has_admin_comment=EXISTS(
SELECT 1 FROM submission_comments AS sc, assignments AS a, courses AS c, enrollments AS e
WHERE sc.submission_id = submissions.id AND a.id = submissions.assignment_id
AND c.id = a.context_id AND a.context_type = 'Course' AND e.course_id = c.id
AND e.user_id = sc.author_id AND e.workflow_state = 'active'
AND e.type IN ('TeacherEnrollment', 'TaEnrollment'))
WHERE id = NEW.submission_id;
SQL_ACTIONS
end
create_trigger("submission_comments_after_delete_row_tr", :generated => true, :compatibility => 1).
on("submission_comments").
after(:delete) do
<<-SQL_ACTIONS
UPDATE submissions
SET has_admin_comment=EXISTS(
SELECT 1 FROM submission_comments AS sc, assignments AS a, courses AS c, enrollments AS e
WHERE sc.submission_id = submissions.id AND a.id = submissions.assignment_id
AND c.id = a.context_id AND a.context_type = 'Course' AND e.course_id = c.id
AND e.user_id = sc.author_id AND e.workflow_state = 'active'
AND e.type IN ('TeacherEnrollment', 'TaEnrollment'))
WHERE id = OLD.submission_id;
SQL_ACTIONS
end
end
def self.down
drop_trigger("submission_comments_after_insert_row_tr", "submission_comments")
drop_trigger("submission_comments_after_delete_row_tr", "submission_comments")
end
end

View File

@ -1,44 +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/>.
class ContextToConversationNotificationPreferences < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
if message = Notification.where(category: "Message", name: "Teacher Context Message").first
if conversation_message = Notification.where(category: "Conversation Message").first
execute <<-SQL
INSERT INTO #{NotificationPolicy.quoted_table_name}
(notification_id, user_id, communication_channel_id, broadcast, frequency)
SELECT #{conversation_message.id}, user_id, communication_channel_id, broadcast, frequency
FROM #{NotificationPolicy.quoted_table_name} WHERE notification_id=#{message.id};
SQL
end
if added_to_conversation = Notification.where(category: "Added To Conversation").first
execute <<-SQL
INSERT INTO #{NotificationPolicy.quoted_table_name}
(notification_id, user_id, communication_channel_id, broadcast, frequency)
SELECT #{added_to_conversation.id}, user_id, communication_channel_id, broadcast, frequency
FROM #{NotificationPolicy.quoted_table_name} WHERE notification_id=#{message.id}
SQL
end
end
end
def self.down
end
end

View File

@ -1,46 +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/>.
class AddExternalToolFlags < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :context_external_tools, :has_user_navigation, :boolean
add_column :context_external_tools, :has_course_navigation, :boolean
add_column :context_external_tools, :has_account_navigation, :boolean
add_column :context_external_tools, :has_resource_selection, :boolean
add_column :context_external_tools, :has_editor_button, :boolean
add_index :context_external_tools, [:context_id, :context_type, :has_user_navigation], :name => "external_tools_user_navigation"
add_index :context_external_tools, [:context_id, :context_type, :has_course_navigation], :name => "external_tools_course_navigation"
add_index :context_external_tools, [:context_id, :context_type, :has_account_navigation], :name => "external_tools_account_navigation"
add_index :context_external_tools, [:context_id, :context_type, :has_resource_selection], :name => "external_tools_resource_selection"
add_index :context_external_tools, [:context_id, :context_type, :has_editor_button], :name => "external_tools_editor_button"
end
def self.down
remove_column :context_external_tools, :has_user_navigation
remove_column :context_external_tools, :has_course_navigation
remove_column :context_external_tools, :has_account_navigation
remove_column :context_external_tools, :has_resource_selection
remove_column :context_external_tools, :has_editor_button
remove_index :context_external_tools, [:context_id, :context_type, :has_user_navigation]
remove_index :context_external_tools, [:context_id, :context_type, :has_course_navigation]
remove_index :context_external_tools, [:context_id, :context_type, :has_account_navigation]
remove_index :context_external_tools, [:context_id, :context_type, :has_resource_selection]
remove_index :context_external_tools, [:context_id, :context_type, :has_editor_button]
end
end

View File

@ -1,28 +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/>.
class RemoveInactiveEnrollmentState < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
Delayed::Backend::ActiveRecord::Job.where(:tag => 'EnrollmentDateRestrictions.update_restricted_enrollments').delete_all
Enrollment.where(:workflow_state => 'inactive').update_all(:workflow_state => 'active')
end
def self.down
end
end

View File

@ -1,30 +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/>.
class ConversationMessageContext < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :conversation_messages, :context_id, :integer, :limit => 8
add_column :conversation_messages, :context_type, :string
end
def self.down
remove_column :conversation_messages, :context_id
remove_column :conversation_messages, :context_type
end
end

View File

@ -1,36 +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/>.
class AddUsefulIndexes < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_index :courses, :uuid
add_index :content_tags, [ :associated_asset_id, :associated_asset_type ], :name => 'index_content_tags_on_associated_asset'
add_index :discussion_entries, :parent_id
add_index :learning_outcomes, [ :context_id, :context_type ]
add_index :role_overrides, :context_code
end
def self.down
remove_index :courses, :uuid
remove_index :content_tags, :name => 'index_content_tags_on_associated_asset'
remove_index :discussion_entries, :parent_id
remove_index :learning_outcomes, [ :context_id, :context_type ]
remove_index :role_overrides, :context_code
end
end

View File

@ -1,28 +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/>.
class AddGradingStandardsVersion < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :grading_standards, :version, :integer
end
def self.down
remove_column :grading_standards, :version
end
end

View File

@ -1,38 +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/>.
class ConversationsCountFix < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
update "UPDATE #{ConversationParticipant.quoted_table_name} SET workflow_state = 'read' WHERE workflow_state = 'unread' AND last_message_at IS NULL"
update <<-SQL
UPDATE #{User.quoted_table_name}
SET unread_conversations_count = (
SELECT COUNT(*)
FROM #{ConversationParticipant.quoted_table_name}
WHERE workflow_state = 'unread'
AND last_message_at IS NOT NULL
AND user_id = users.id
)
SQL
end
def self.down
end
end

View File

@ -1,28 +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/>.
class AddReplacementCourseIdToCourses < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :courses, :replacement_course_id, :integer, :limit => 8
end
def self.down
remove_column :courses, :replacement_course_id
end
end

View File

@ -1,43 +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/>.
class ClearSisWhitespace < ActiveRecord::Migration[4.2]
tag :predeploy
def self.clear(table, *cols)
cols = cols.map{|col|" #{col} = TRIM(#{col})"}.join(',')
update("UPDATE #{connection.quote_table_name(table)} SET #{cols}")
end
def self.up
clear(:pseudonyms, :unique_id, :sis_source_id, :sis_user_id)
clear(:users, :name, :sis_name)
clear(:enrollment_terms, :name, :sis_name, :sis_source_id)
clear(:course_sections, :name, :sis_name, :sis_source_id)
clear(:groups, :name, :sis_name, :sis_source_id)
clear(:courses, :name, :sis_name, :sis_source_id, :course_code, :sis_course_code)
clear(:abstract_courses, :name, :sis_name, :sis_source_id, :short_name, :sis_course_code)
clear(:course_sections, :name, :sis_name, :sis_source_id)
clear(:enrollments, :sis_source_id)
clear(:accounts, :name, :sis_name, :sis_source_id)
end
def self.down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -1,101 +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/>.
class AddDelayedJobsNextInStrand < ActiveRecord::Migration[4.2]
tag :predeploy
def self.connection
Delayed::Backend::ActiveRecord::Job.connection
end
def self.up
raise("#{connection.adapter_name} is not supported for delayed jobs queue") unless %w(PostgreSQL MySQL Mysql2 SQLite).include?(connection.adapter_name)
remove_index :delayed_jobs, :name => 'index_delayed_jobs_for_get_next'
add_column :delayed_jobs, :next_in_strand, :boolean, :default => true, :null => false
# create the new index
case connection.adapter_name
when 'PostgreSQL'
connection.execute("CREATE INDEX get_delayed_jobs_index ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} (priority, run_at) WHERE locked_at IS NULL AND queue = 'canvas_queue' AND next_in_strand = 't'")
else
add_index :delayed_jobs, %w(priority run_at locked_at queue next_in_strand), :name => 'get_delayed_jobs_index'
end
# create the insert trigger
case connection.adapter_name
when 'PostgreSQL'
execute(<<-CODE)
CREATE FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')} () RETURNS trigger AS $$
BEGIN
LOCK delayed_jobs IN SHARE ROW EXCLUSIVE MODE;
IF (SELECT 1 FROM delayed_jobs WHERE strand = NEW.strand LIMIT 1) = 1 THEN
NEW.next_in_strand := 'f';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CODE
execute("CREATE TRIGGER delayed_jobs_before_insert_row_tr BEFORE INSERT ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} FOR EACH ROW WHEN (NEW.strand IS NOT NULL) EXECUTE PROCEDURE #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')}()")
when 'MySQL', 'Mysql2'
execute(<<-CODE)
CREATE TRIGGER delayed_jobs_before_insert_row_tr BEFORE INSERT ON delayed_jobs
FOR EACH ROW
BEGIN
IF NEW.strand IS NOT NULL THEN
IF (SELECT 1 FROM delayed_jobs WHERE strand = NEW.strand LIMIT 1) = 1 THEN
SET NEW.next_in_strand = 0;
END IF;
END IF;
END;
CODE
when 'SQLite'
execute(<<-CODE)
CREATE TRIGGER delayed_jobs_after_insert_row_tr AFTER INSERT ON delayed_jobs
FOR EACH ROW WHEN (NEW.strand IS NOT NULL)
BEGIN
UPDATE delayed_jobs SET next_in_strand = 0 WHERE id = NEW.id AND id <> (SELECT id FROM delayed_jobs j2 WHERE j2.strand = NEW.strand ORDER BY j2.strand, j2.id ASC LIMIT 1);
END;
CODE
end
# create the delete trigger
execute(<<-CODE)
CREATE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
BEGIN
UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1);
RETURN OLD;
END;
$$ LANGUAGE plpgsql;
CODE
execute("CREATE TRIGGER delayed_jobs_after_delete_row_tr AFTER DELETE ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} FOR EACH ROW WHEN (OLD.strand IS NOT NULL AND OLD.next_in_strand = 't') EXECUTE PROCEDURE #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')}()")
update(%{UPDATE #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} SET next_in_strand = 'f' WHERE strand IS NOT NULL AND id <> (SELECT id FROM #{Delayed::Backend::ActiveRecord::Job.quoted_table_name} j2 WHERE j2.strand = delayed_jobs.strand ORDER BY j2.strand, j2.id ASC LIMIT 1)})
end
def self.down
execute %{DROP TRIGGER delayed_jobs_before_insert_row_tr ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name}}
execute %{DROP FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')}()}
execute %{DROP TRIGGER delayed_jobs_after_delete_row_tr ON #{Delayed::Backend::ActiveRecord::Job.quoted_table_name}}
execute %{DROP FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')}()}
remove_column :delayed_jobs, :next_in_strand
remove_index :delayed_jobs, :name => 'get_delayed_jobs_index'
add_index :delayed_jobs, %w(run_at queue locked_at strand priority), :name => 'index_delayed_jobs_for_get_next'
end
end

View File

@ -1,28 +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/>.
class DropMailboxes < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
drop_table :mailboxes
drop_table :mailboxes_pseudonyms
end
def self.down
end
end

View File

@ -1,31 +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/>.
class DropContextCodeFromRoleOverride < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
remove_index :role_overrides, :context_code
remove_column :role_overrides, :context_code
end
def self.down
add_column :role_overrides, :context_code, :string
add_index :role_overrides, :context_code
RoleOverride.update_all("context_code=LOWER(context_type) || '_' || context_id")
end
end

View File

@ -1,36 +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/>.
class DropMovedInAccountStructure < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
remove_index :users, :moved_in_account_structure
remove_column :users, :moved_in_account_structure
remove_index :courses, [:moved_in_account_structure, :updated_at]
remove_column :courses, :moved_in_account_structure
remove_column :accounts, :moved_in_account_structure
end
def self.down
add_column :accounts, :moved_in_account_structure, :boolean, :default => true
add_column :courses, :moved_in_account_structure, :boolean, :default => true
add_index :courses, [:moved_in_account_structure, :updated_at]
add_column :users, :moved_in_account_structure, :boolean, :default => true
add_index :users, :moved_in_account_structure
end
end

View File

@ -1,28 +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/>.
class DropTypeFromUsers < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
remove_column :users, :type
end
def self.down
add_column :users, :type, :string
end
end

View File

@ -1,28 +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/>.
class AddParametersToCourseImports < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :course_imports, :parameters, :text
end
def self.down
remove_column :course_imports, :parameters
end
end

View File

@ -1,28 +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/>.
class TurnitinSettings < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :assignments, :turnitin_settings, :text
end
def self.down
remove_column :assignments, :turnitin_settings
end
end

View File

@ -1,30 +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/>.
class RemoveSectionAndHiddenTabsFromCourses < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
remove_column :courses, :section
remove_column :courses, :hidden_tabs
end
def self.down
add_column :courses, :section, :string
add_column :courses, :hidden_tabs, :text
end
end

View File

@ -1,29 +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/>.
class AddMutedToAssignments < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :assignments, :muted, :boolean, :default => false
Assignment.update_all :muted => false
end
def self.down
remove_column :assignments, :muted
end
end

View File

@ -1,33 +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/>.
class AddDelayedJobsShardId < ActiveRecord::Migration[4.2]
tag :predeploy
def self.connection
Delayed::Backend::ActiveRecord::Job.connection
end
def self.up
add_column :delayed_jobs, :shard_id, :integer, :limit => 8
Delayed::Backend::ActiveRecord::Job.reset_column_information
end
def self.down
remove_column :delayed_jobs, :shard_id
end
end

View File

@ -1,42 +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/>.
class GenericSisStickinessRefactorColumns < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :abstract_courses, :stuck_sis_fields, :text
add_column :accounts, :stuck_sis_fields, :text
add_column :courses, :stuck_sis_fields, :text
add_column :groups, :stuck_sis_fields, :text
add_column :course_sections, :stuck_sis_fields, :text
add_column :enrollment_terms, :stuck_sis_fields, :text
add_column :users, :stuck_sis_fields, :text
end
def self.down
drop_column :users, :stuck_sis_fields
drop_column :enrollment_terms, :stuck_sis_fields
drop_column :course_sections, :stuck_sis_fields
drop_column :groups, :stuck_sis_fields
drop_column :courses, :stuck_sis_fields
drop_column :accounts, :stuck_sis_fields
drop_column :abstract_courses, :stuck_sis_fields
end
end

View File

@ -1,75 +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/>.
class GenericSisStickinessRefactorData < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
update <<-SQL
UPDATE #{AbstractCourse.quoted_table_name} SET stuck_sis_fields =
(CASE WHEN sis_name <> name THEN
(CASE WHEN sis_course_code <> short_name THEN
'name,short_name'
ELSE
'name'
END)
WHEN sis_course_code <> short_name THEN
'short_name'
ELSE
NULL
END);
SQL
update <<-SQL
UPDATE #{Course.quoted_table_name} SET stuck_sis_fields =
(CASE WHEN sis_name <> name THEN
(CASE WHEN sis_course_code <> course_code THEN
'name,course_code'
ELSE
'name'
END)
WHEN sis_course_code <> course_code THEN
'course_code'
ELSE
NULL
END);
SQL
update <<-SQL
UPDATE #{CourseSection.quoted_table_name} SET stuck_sis_fields =
(CASE WHEN sis_name <> name THEN
(CASE WHEN sticky_xlist THEN
'course_id,name'
ELSE
'name'
END)
WHEN sticky_xlist THEN
'course_id'
ELSE
NULL
END);
SQL
Account.where("sis_name<>name").update_all(stuck_sis_fields: 'name')
Group.where("sis_name<>name").update_all(stuck_sis_fields: 'name')
EnrollmentTerm.where("sis_name<>name").update_all(stuck_sis_fields: 'name')
User.where("sis_name<>name").update_all(stuck_sis_fields: 'name')
end
def self.down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -1,29 +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/>.
class AddHiddenToSubmissionComments < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :submission_comments, :hidden, :boolean, :default => false
SubmissionComment.update_all :hidden => false
end
def self.down
drop_column :submission_comments
end
end

View File

@ -1,30 +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/>.
class RemoveUnusedSisDataFields < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
remove_column :pseudonyms, :sis_update_data
remove_column :enrollment_terms, :sis_data
end
def self.down
add_column :enrollment_terms, :sis_data, :text
add_column :pseudonyms, :sis_update_data, :text
end
end