squash old migrations, p30

Change-Id: Ic70fd33a97c388cf4e1a1dfd6ad26c023f5f3040
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/236782
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
This commit is contained in:
Simon Williams 2020-05-08 20:25:19 -05:00
parent 029c20dff1
commit 9535bee361
32 changed files with 43 additions and 916 deletions

View File

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

@ -569,7 +569,9 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.integer "participants_per_appointment"
t.boolean "override_participants_per_appointment"
t.text "comments"
t.string "timetable_code"
end
add_index :calendar_events, [:context_id, :context_type, :timetable_code], where: "timetable_code IS NOT NULL", unique: true, name: "index_calendar_events_on_context_and_timetable_code"
create_table :bookmarks_bookmarks do |t|
t.integer :user_id, limit: 8, null: false
@ -608,10 +610,10 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.integer :attachment_id, limit: 8, null: false
t.timestamps null: true
t.boolean :has_annotations
t.string :preferred_plugin_course_id
end
add_index :canvadocs, :document_id, :unique => true
add_index :canvadocs, :attachment_id
add_index :canvadocs, :process_state
create_table :canvadocs_submissions do |t|
t.integer :canvadoc_id, limit: 8
@ -822,17 +824,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string :app_center_id
end
add_index :context_external_tools, [:tool_id]
create_table "context_message_participants", :force => true do |t|
t.integer "user_id", :limit => 8
t.integer "context_message_id", :limit => 8
t.string "participation_type"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "context_message_participants", ["context_message_id"], :name => "index_context_message_participants_on_context_message_id"
add_index "context_message_participants", ["user_id"], :name => "index_context_message_participants_on_user_id"
add_index :context_external_tools, [:context_id, :context_type]
create_table "context_module_progressions", :force => true do |t|
t.integer "context_module_id", :limit => 8
@ -942,7 +934,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.boolean "has_media_objects"
end
add_index "conversation_messages", ["conversation_id", "created_at"]
execute("CREATE INDEX index_conversation_messages_on_asset_id_and_asset_type ON #{ConversationMessage.quoted_table_name} (asset_id, asset_type) WHERE asset_id IS NOT NULL")
add_index :conversation_messages, :author_id
create_table "conversation_message_participants" do |t|
@ -951,10 +942,12 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.text "tags"
t.integer "user_id", :limit => 8
t.string "workflow_state"
t.datetime "deleted_at"
end
add_index :conversation_message_participants, [:conversation_participant_id, :conversation_message_id], :name => :index_cmp_on_cpi_and_cmi
add_index :conversation_message_participants, [:user_id, :conversation_message_id], :name => "index_conversation_message_participants_on_uid_and_message_id", :unique => true
add_index :conversation_message_participants, :conversation_message_id, :name => "index_conversation_message_participants_on_message_id"
add_index :conversation_message_participants, :deleted_at
create_table "course_account_associations", :force => true do |t|
t.integer "course_id", :limit => 8, :null => false
@ -1120,7 +1113,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "send_at"
t.string "link"
t.text "link"
t.text "name_of_topic"
t.text "summary"
t.integer "root_account_id", :limit => 8
@ -1291,12 +1284,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.boolean :restricted_access, null: false, default: false
t.boolean :access_is_current, null: false, default: false
# these will go away - for initial diagnostic purposes
t.datetime :state_invalidated_at
t.datetime :state_recalculated_at
t.datetime :access_invalidated_at
t.datetime :access_recalculated_at
end
add_index :enrollment_states, :enrollment_id, :unique => true, :name => "index_enrollment_states"
@ -1620,6 +1607,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
# accidentally lost the limit: 8 on this foreign key
# (went from bigint -> int). needs to be fixed.
t.integer :grading_period_group_id, null: false
t.datetime :close_date
end
add_index :grading_periods, :grading_period_group_id
add_index :grading_periods, :workflow_state
@ -2032,6 +2020,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.timestamps null: true
t.boolean :final, null: false, default: false
t.integer :source_provisional_grade_id, limit: 8
t.boolean :graded_anonymously
end
add_index :moderated_grading_provisional_grades, :submission_id
add_index :moderated_grading_provisional_grades,
@ -2044,6 +2033,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
:unique => true,
:name => :idx_mg_provisional_grades_unique_sub_scorer_when_not_final,
:where => "final = FALSE"
add_index :moderated_grading_provisional_grades, :source_provisional_grade_id, name: 'index_provisional_grades_on_source_grade', where: "source_provisional_grade_id IS NOT NULL"
create_table :moderated_grading_selections do |t|
t.integer :assignment_id, limit: 8, null: false
@ -2052,11 +2042,12 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
add_index :moderated_grading_selections, :assignment_id
add_index :moderated_grading_selections,
[:assignment_id, :student_id],
unique: true,
name: :idx_mg_selections_unique_on_assignment_and_student
add_index :moderated_grading_selections, :selected_provisional_grade_id, name: 'index_moderated_grading_selections_on_selected_grade', where: "selected_provisional_grade_id IS NOT NULL"
add_index :moderated_grading_selections, :student_id
create_table :notification_endpoints do |t|
t.integer :access_token_id, limit: 8, null: false
@ -2688,7 +2679,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index :stream_items, [:asset_type, :asset_id], :unique => true
add_index :stream_items, :updated_at
add_index :stream_items, :notification_category
create_table "submission_comment_participants", :force => true do |t|
t.integer "submission_comment_id", :limit => 8
@ -2728,6 +2718,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "submission_comments", ["context_id", "context_type"], :name => "index_submission_comments_on_context_id_and_context_type"
add_index "submission_comments", ["submission_id"], :name => "index_submission_comments_on_submission_id"
add_index :submission_comments, :draft
add_index :submission_comments, :provisional_grade_id, where: "provisional_grade_id IS NOT NULL"
create_table :submission_versions do |t|
t.integer "context_id", :limit => 8
@ -2957,6 +2948,14 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
if (trgm = connection.extension_installed?(:pg_trgm))
add_index :users, "lower(name) #{trgm}.gist_trgm_ops", name: "index_trgm_users_name", using: :gist
add_index :users, "LOWER(short_name) #{trgm}.gist_trgm_ops", name: "index_trgm_users_short_name", using: :gist
add_index :users, "LOWER(short_name) #{trgm}.gist_trgm_ops",
name: "index_trgm_users_short_name_active_only",
using: :gist,
where: "workflow_state IN ('registered', 'pre_registered')"
add_index :users, "LOWER(name) #{trgm}.gist_trgm_ops",
name: "index_trgm_users_name_active_only",
using: :gist,
where: "workflow_state IN ('registered', 'pre_registered')"
end
add_index :users, :lti_context_id, :unique => true
add_index :users, :turnitin_id, unique: true, where: "turnitin_id IS NOT NULL"

View File

@ -68,23 +68,27 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2]
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,
graded_anonymously boolean,
excused_before boolean,
excused_after boolean
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,
graded_anonymously boolean,
excused_before boolean,
excused_after boolean,
score_before double,
score_after double,
points_possible_before double,
points_possible_after double
) #{compression_params}}
indexes.each do |index_name|

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class FixOldSubmissionVersionYaml < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
DataFixup::FixOldSubmissionVersionYAML.send_later_if_production_enqueue_args(:run, :priority => Delayed::LOW_PRIORITY)
end
def down
end
end

View File

@ -1,38 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class UpdateSettingEquationSvgUrlDefault < ActiveRecord::Migration[4.2]
tag :predeploy
def up
return unless Shard.current.default?
setting = Setting.where(name: 'codecogs.equation_image_link').take
if setting.present?
Setting.set('equation_image_url', "#{setting.value}?")
end
end
def down
return unless Shard.current.default?
setting = Setting.where(name: 'equation_image_url').take
if setting.present?
Setting.set('codecogs.equation_image_link', setting.value.sub(/\?$/, ''))
end
end
end

View File

@ -1,32 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class RemoveCodecogsEquationImageSettingKey < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
return unless Shard.current.default?
Setting.remove('codecogs.equation_image_link')
end
def down
return unless Shard.current.default?
Setting.remove('equation_image_url')
end
end

View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class MoveSamlEntityIdToAccount < ActiveRecord::Migration[4.2]
tag :postdeploy
class AuthenticationProvider < ActiveRecord::Base
self.table_name = 'account_authorization_configs'
end
def up
AuthenticationProvider.where(workflow_state: 'active', auth_type: 'saml').where.not(entity_id: nil).each do |ap|
ap.account.settings[:saml_entity_id] ||= ap.entity_id
ap.account.save!
end
end
end

View File

@ -1,40 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddCassandraGradeChangeScore < ActiveRecord::Migration[4.2]
tag :predeploy
include Canvas::Cassandra::Migration
def self.cassandra_cluster
'auditors'
end
def self.up
cassandra.execute %{ ALTER TABLE grade_changes ADD score_before double; }
cassandra.execute %{ ALTER TABLE grade_changes ADD score_after double; }
cassandra.execute %{ ALTER TABLE grade_changes ADD points_possible_before double; }
cassandra.execute %{ ALTER TABLE grade_changes ADD points_possible_after double; }
end
def self.down
cassandra.execute %{ ALTER TABLE grade_changes DROP score_before; }
cassandra.execute %{ ALTER TABLE grade_changes DROP score_after; }
cassandra.execute %{ ALTER TABLE grade_changes DROP points_possible_before; }
cassandra.execute %{ ALTER TABLE grade_changes DROP points_possible_after; }
end
end

View File

@ -1,24 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class ChangeGroupWorkflowStates < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
Group.where(workflow_state: ['closed', 'completed']).update_all(workflow_state: 'available')
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class ModeratedGradingForeignKeyIndexes < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def change
add_index :submission_comments, :provisional_grade_id, where: "provisional_grade_id IS NOT NULL", algorithm: :concurrently
add_index :moderated_grading_provisional_grades, :source_provisional_grade_id, name: 'index_provisional_grades_on_source_grade', where: "source_provisional_grade_id IS NOT NULL", algorithm: :concurrently
add_index :moderated_grading_selections, :selected_provisional_grade_id, name: 'index_moderated_grading_selections_on_selected_grade', where: "selected_provisional_grade_id IS NOT NULL", algorithm: :concurrently
# this index is useless; the index on [assignment_id, student_id] already covers it
remove_index :moderated_grading_selections, column: :assignment_id
add_index :moderated_grading_selections, :student_id, algorithm: :concurrently
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class RemoveDelayedMessagesLinkLengthLimit < ActiveRecord::Migration[4.2]
tag :predeploy
def up
change_column :delayed_messages, :link, :text
end
def down
change_column :delayed_messages, :link, :text, length: 255
end
end

View File

@ -1,24 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddGradedAnonymouslyToProvisionalGrade < ActiveRecord::Migration[4.2]
tag :predeploy
def change
add_column :moderated_grading_provisional_grades, :graded_anonymously, :boolean
end
end

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class ResetNegativeUnreadCounts < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
DataFixup::ResetNegativeUnreadCounts.send_later_if_production_enqueue_args(:run, :priority => Delayed::LOW_PRIORITY)
end
def down
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddCloseDateToGradingPeriods < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :grading_periods, :close_date, :datetime
end
def self.down
remove_column :grading_periods, :close_date
end
end

View File

@ -1,25 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class PopulateGradingPeriodCloseDates < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
DataFixup::PopulateGradingPeriodCloseDates.run
end
end

View File

@ -1,24 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddPreferredPluginCourseIdToCanvadocs < ActiveRecord::Migration[4.2]
tag :predeploy
def change
add_column :canvadocs, :preferred_plugin_course_id, :string
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class TouchDiscussionTopics < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
# mark all materialized views as out of date
DiscussionTopic.send_later_if_production_enqueue_args(:touch_all_records, :priority => Delayed::LOW_PRIORITY)
end
def down
end
end

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddTimetableCodeToCalendarEvents < ActiveRecord::Migration[4.2]
tag :predeploy
disable_ddl_transaction!
def change
add_column :calendar_events, :timetable_code, :string
add_index :calendar_events, [:context_id, :context_type, :timetable_code], where: "timetable_code IS NOT NULL",
unique: true, algorithm: :concurrently, name: "index_calendar_events_on_context_and_timetable_code"
end
end

View File

@ -1,38 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddUserActiveOnlyGistIndexes < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
tag :postdeploy
def self.up
if schema = connection.extension_installed?(:pg_trgm)
# next line indexes the wrong column, so it's nuked and another migration adds the right one and fixes up
# people who already ran this migration
add_index :users, "LOWER(short_name) #{schema}.gist_trgm_ops",
name: "index_trgm_users_short_name_active_only",
using: :gist,
algorithm: :concurrently,
where: "workflow_state IN ('registered', 'pre_registered')"
end
end
def self.down
remove_index :users, name: 'index_trgm_users_name_active_only' if index_name_exists?(:users, 'index_trgm_users_name_active_only', false)
remove_index :users, name: 'index_trgm_users_short_name_active_only'
end
end

View File

@ -1,45 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class FixUserActiveOnlyGistIndexes < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
tag :postdeploy
def self.up
if schema = connection.extension_installed?(:pg_trgm)
remove_index :users, name: 'index_trgm_users_name_active_only' if index_name_exists?(:users, 'index_trgm_users_name_active_only', false)
add_index :users, "LOWER(name) #{schema}.gist_trgm_ops",
name: "index_trgm_users_name_active_only",
using: :gist,
algorithm: :concurrently,
where: "workflow_state IN ('registered', 'pre_registered')"
end
end
def self.down
if schema = connection.extension_installed?(:pg_trgm)
remove_index :users, name: 'index_trgm_users_name_active_only' if index_name_exists?(:users, 'index_trgm_users_name_active_only', false)
add_index :users, "LOWER(short_name) #{schema}.gist_trgm_ops",
name: "index_trgm_users_short_name_active_only",
using: :gist,
algorithm: :concurrently,
where: "workflow_state IN ('registered', 'pre_registered')"
end
end
end

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddDeletedAtToConversationMessageParticipants < ActiveRecord::Migration[4.2]
tag :predeploy
disable_ddl_transaction!
def change
add_column :conversation_message_participants, :deleted_at, :datetime
add_index :conversation_message_participants, :deleted_at, algorithm: :concurrently
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class FixRidiculousWebConferenceDurations < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
tag :postdeploy
def self.up
WebConference.where('duration>?', WebConference::MAX_DURATION).find_ids_in_ranges do |min, max|
WebConference.where('duration>?', WebConference::MAX_DURATION)
.where(:id => min..max)
.update_all(duration: nil)
end
end
end

View File

@ -1,34 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class DropEnrollmentStateLogColumns < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
remove_column :enrollment_states, :state_invalidated_at
remove_column :enrollment_states, :state_recalculated_at
remove_column :enrollment_states, :access_invalidated_at
remove_column :enrollment_states, :access_recalculated_at
end
def down
add_column :enrollment_states, :state_invalidated_at, :datetime
add_column :enrollment_states, :state_recalculated_at, :datetime
add_column :enrollment_states, :access_invalidated_at, :datetime
add_column :enrollment_states, :access_recalculated_at, :datetime
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 DropContextMessageParticipants < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
drop_table :context_message_participants
end
def down
# we could recreate the tables, but we can't recover the data;
# use a backup if you really need to revert this
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class DropUnusedIndices2 < ActiveRecord::Migration[4.2]
tag :postdeploy
def change
remove_index :conversation_messages, [:asset_id, :asset_type]
remove_index :stream_items, :notification_category
remove_index :canvadocs, :process_state
end
end

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class RedoPartiallyAppliedIndexes < ActiveRecord::Migration[4.2]
tag :postdeploy
def up
if index_exists?(:attachments, [:folder_id, :file_state, :display_name], name: "index_attachments_on_folder_id_and_file_state_and_display_name2")
remove_index "attachments", name: "index_attachments_on_folder_id_and_file_state_and_display_name2"
end
end
end

View File

@ -1,25 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddContextIndexToExternalTools < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
tag :postdeploy
def change
add_index :context_external_tools, [:context_id, :context_type], algorithm: :concurrently
end
end

View File

@ -1,37 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module DataFixup
module FixOldSubmissionVersionYAML
def self.run
Version.find_ids_in_ranges do |min_id, max_id|
Version.where(:id => min_id..max_id, :versionable_type => "Submission").
where("yaml LIKE ?", "%cached_due_date: !ruby/string%").each do |version|
begin
yaml = version.yaml.sub("cached_due_date: !ruby/string", "cached_due_date: ")
obj = YAML.load(yaml)
obj["cached_due_date"] = Time.parse(obj["cached_due_date"]["str"])
version.yaml = YAML.dump(obj)
version.save!
rescue
Rails.logger.error("Error occured trying to process Version #{version.global_id}")
end
end
end
end
end
end

View File

@ -1,25 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module DataFixup::PopulateGradingPeriodCloseDates
def self.run
GradingPeriod.
where(close_date: nil).
where.not(end_date: nil).
update_all("close_date=end_date")
end
end

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module DataFixup
module ResetNegativeUnreadCounts
def self.run
User.find_ids_in_ranges do |min_id, max_id|
User.where(:id => min_id..max_id).where("unread_conversations_count < 0").update_all(:unread_conversations_count => 0)
end
end
end
end

View File

@ -1,46 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
require 'spec_helper'
describe DataFixup::PopulateGradingPeriodCloseDates do
before(:each) do
root_account = Account.create(name: 'new account')
group = Factories::GradingPeriodGroupHelper.new.create_for_account(root_account)
period_helper = Factories::GradingPeriodHelper.new
@first_period = period_helper.create_presets_for_group(group, :past).first
@first_period.close_date = nil
@first_period.save!
@second_period = period_helper.create_presets_for_group(group, :current).first
@second_period.close_date = 3.days.from_now(@second_period.end_date)
@second_period.save!
end
before(:each) do
DataFixup::PopulateGradingPeriodCloseDates.run
end
it "does not alter already-set close dates" do
@second_period.reload
expect(@second_period.close_date).to eq 3.days.from_now(@second_period.end_date)
end
it "sets the close date to the end date for periods with nil close dates" do
@first_period.reload
expect(@first_period.close_date).to eq @first_period.end_date
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
require_relative "../spec_helper"
require 'db/migrate/20160805163609_fix_ridiculous_web_conference_durations.rb'
describe FixRidiculousWebConferenceDurations do
it "sets ridiculously long conferences as long-running" do
course_with_teacher
allow(WebConference).to receive(:conference_types).and_return([{conference_type: 'test', class_name: 'WebConference'}])
conf = course_factory.web_conferences.create!(user: @teacher, conference_type: 'test')
conf.update_attribute(:duration, WebConference::MAX_DURATION + 1)
FixRidiculousWebConferenceDurations.up
expect(conf.reload.duration).to be_nil
end
end