squash old migrations, p18

Change-Id: I9421b33d2708b03b25538984d2583e9476c820ba
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/226126
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-02-06 16:44:39 -06:00
parent 2213528422
commit 91883f9063
45 changed files with 111 additions and 1740 deletions

View File

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

@ -335,8 +335,8 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "membership_type"
end
add_index "asset_user_accesses", ["context_id", "context_type"], :name => "index_asset_user_accesses_on_context_id_and_context_type"
add_index "asset_user_accesses", ["user_id", "asset_code"], :name => "index_asset_user_accesses_on_user_id_and_asset_code"
add_index :asset_user_accesses, [:context_id, :context_type, :user_id, :updated_at], name: 'index_asset_user_accesses_on_ci_ct_ui_ua'
create_table "assignment_groups", :force => true do |t|
t.string "name"
@ -454,6 +454,9 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.integer "group_category_id", :limit => 8
t.boolean "freeze_on_copy"
t.boolean "copied"
t.boolean "only_visible_to_overrides"
t.boolean "post_to_sis"
t.string "integration_id"
end
add_index "assignments", ["assignment_group_id"], :name => "index_assignments_on_assignment_group_id"
@ -613,62 +616,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "collaborators", ["user_id"], :name => "index_collaborators_on_user_id"
add_index :collaborators, [:group_id], :name => 'index_collaborators_on_group_id'
create_table :collections do |t|
t.string :name
t.string :visibility, :default => "private"
t.string :context_type, :null => false
t.integer :context_id, :limit => 8, :null => false
t.string :workflow_state, :null => false
t.timestamps null: true
t.integer :followers_count, :default => 0
t.integer :items_count, :default => 0
end
add_index :collections, [:context_id, :context_type, :workflow_state, :visibility], :name => "index_collections_for_finding"
create_table :collection_items do |t|
t.integer :collection_item_data_id, :limit => 8, :null => false
t.integer :collection_id, :limit => 8, :null => false
t.string :workflow_state, :null => false
t.text :user_comment
t.timestamps null: true
t.integer :user_id, :limit => 8, :null => false
end
add_index :collection_items, [:collection_id, :workflow_state]
add_index :collection_items, [:collection_item_data_id, :workflow_state], :name => "index_collection_items_on_data_id"
create_table :collection_item_datas do |t|
t.string :item_type
t.text :link_url, :null => false
t.integer :root_item_id, :limit => 8
t.integer :post_count, :default => 0
t.integer :upvote_count, :default => 0
t.timestamps null: true
t.boolean :image_pending
t.integer :image_attachment_id, :limit => 8
t.text :image_url
t.text :html_preview
t.string :title
t.text :description
end
create_table :collection_item_upvotes do |t|
t.integer :collection_item_data_id, :limit => 8, :null => false
t.integer :user_id, :limit => 8, :null => false
t.timestamps null: true
end
add_index :collection_item_upvotes, [:collection_item_data_id, :user_id], :unique => true, :name => "index_collection_item_upvotes_join"
create_table "communication_channels", :force => true do |t|
t.string "path", :null => false
t.string "path_type", :default => "email", :null => false
@ -786,8 +733,8 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string :context_type
t.string :domain
t.string :url, :limit => 4.kilobytes
t.string :shared_secret, :null => false
t.string :consumer_key, :null => false
t.text :shared_secret, :null => false
t.text :consumer_key, :null => false
t.string :name, :null => false
t.text :description
t.text :settings
@ -833,6 +780,8 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.boolean "collapsed"
t.integer "current_position"
t.datetime "completed_at"
t.boolean "current"
t.integer "lock_version", :default => 0
end
add_index "context_module_progressions", ["context_module_id"], :name => "index_context_module_progressions_on_context_module_id"
@ -1064,6 +1013,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string :uuid
t.string :process_state
t.integer :attachment_id, :limit => 8
t.timestamps null: true
end
add_index :crocodoc_documents, :uuid
add_index :crocodoc_documents, :attachment_id
@ -1071,23 +1021,34 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
create_table :custom_gradebook_columns do |t|
t.string :title, :null => false
t.integer :position
t.string :workflow_state, :default => "active"
t.integer :course_id, :limit => 8
t.integer :position, :null => false
t.string :workflow_state, :default => "active", :null => false
t.integer :course_id, :limit => 8, :null => false
t.timestamps null: true
t.boolean :teacher_notes, :default => false
t.boolean :teacher_notes, :default => false, :null => false
end
create_table :custom_gradebook_column_data do |t|
t.string :content
t.integer :user_id, :limit => 8
t.integer :custom_gradebook_column_id, :limit => 8
t.string :content, :null => false
t.integer :user_id, :limit => 8, :null => false
t.integer :custom_gradebook_column_id, :limit => 8, :null => false
end
add_index :custom_gradebook_column_data,
[:custom_gradebook_column_id, :user_id],
:unique => true,
:name => "index_custom_gradebook_column_data_unique_column_and_user"
create_table :data_exports do |t|
t.integer :user_id, :limit => 8, :null => false
t.integer :context_id, :limit => 8, :null => false
t.string :context_type, :null => false
t.string :workflow_state, :null => false
t.datetime :created_at
t.datetime :updated_at
end
add_index :data_exports, [:context_id, :context_type]
add_index :data_exports, :user_id
create_table "delayed_messages", :force => true do |t|
t.integer "notification_id", :limit => 8
t.integer "notification_policy_id", :limit => 8
@ -1137,6 +1098,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "tool_id"
t.string "icon_url"
t.string "sns_arn"
t.boolean "trusted"
end
add_index :developer_keys, [:tool_id], :unique => true
@ -1203,6 +1165,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.datetime "lock_at"
t.boolean "pinned"
t.boolean "locked"
t.integer "group_category_id", :limit => 8
end
add_index "discussion_topics", ["context_id", "position"], :name => "index_discussion_topics_on_context_id_and_position"
@ -1302,11 +1265,30 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "enrollments", ["course_id", "workflow_state"], :name => "index_enrollments_on_course_id_and_workflow_state"
add_index "enrollments", ["course_section_id"], :name => "index_enrollments_on_course_section_id"
add_index "enrollments", ["root_account_id"], :name => "index_enrollments_on_root_account_id"
add_index "enrollments", ["user_id"], :name => "index_enrollments_on_user_id"
add_index "enrollments", ["uuid"], :name => "index_enrollments_on_uuid"
add_index "enrollments", ["workflow_state"], :name => "index_enrollments_on_workflow_state"
add_index :enrollments, [:associated_user_id], :where => "associated_user_id IS NOT NULL"
add_index :enrollments, [:root_account_id, :course_id]
add_index :enrollments,
[:user_id, :type, :role_name, :course_section_id, :associated_user_id],
where: "associated_user_id IS NOT NULL AND role_name IS NOT NULL",
name: 'index_enrollments_on_user_type_role_section_associated_user',
unique: true
add_index :enrollments,
[:user_id, :type, :role_name, :course_section_id],
where: "role_name IS NOT NULL AND associated_user_id IS NULL ",
name: 'index_enrollments_on_user_type_role_section',
unique: true
add_index :enrollments,
[:user_id, :type, :course_section_id, :associated_user_id],
where: "associated_user_id IS NOT NULL AND role_name IS NULL",
name: 'index_enrollments_on_user_type_section_associated_user',
unique: true
add_index :enrollments,
[:user_id, :type, :course_section_id],
where: "associated_user_id IS NULL AND role_name IS NULL",
unique: true
create_table "eportfolio_categories", :force => true do |t|
t.integer "eportfolio_id", :limit => 8, :null => false
@ -1745,12 +1727,13 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "messages", ["notification_id"], :name => "index_messages_on_notification_id"
add_index "messages", ["user_id", "to_email", "dispatch_at"], :name => "index_messages_user_id_dispatch_at_to_email"
add_index :messages, :root_account_id
add_index :messages, :sent_at, where: "sent_at IS NOT NULL"
create_table :migration_issues do |t|
t.integer :content_migration_id, :limit => 8, :null => false
t.text :description
t.string :workflow_state, :null => false
t.string :fix_issue_html_url
t.text :fix_issue_html_url
t.string :issue_type, :null => false
t.integer :error_report_id, :limit => 8
t.text :error_message
@ -1827,7 +1810,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "asset_type"
t.string "controller"
t.string "action"
t.boolean "contributed"
t.float "interaction_seconds"
t.datetime "created_at"
t.datetime "updated_at"
@ -2091,6 +2073,8 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.boolean "cant_go_back"
t.datetime "show_correct_answers_at"
t.datetime "hide_correct_answers_at"
t.boolean "require_lockdown_browser_monitor"
t.text "lockdown_browser_monitor_data"
end
add_index "quizzes", ["assignment_id"], :name => "index_quizzes_on_assignment_id", :unique => true
@ -2254,6 +2238,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.boolean "batch_mode"
t.integer "batch_mode_term_id", :limit => 8
t.text "options"
t.integer "user_id", :limit => 8
end
add_index :sis_batches, [:account_id, :created_at], :where => "workflow_state='created'", name: "index_sis_batches_pending_for_accounts"
add_index :sis_batches, [:account_id, :created_at], :name => "index_sis_batches_account_id_created_at"
@ -2304,7 +2289,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.string "group_comment_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "attachment_ids"
t.text "attachment_ids"
t.integer "assessment_request_id", :limit => 8
t.string "media_comment_id"
t.string "media_comment_type"
@ -2372,6 +2357,14 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "submissions", ["assignment_id", "submission_type"], :name => "index_submissions_on_assignment_id_and_submission_type"
add_index "submissions", ["user_id", "assignment_id"], :name => "index_submissions_on_user_id_and_assignment_id", :unique => true
add_index :submissions, :submitted_at
create_table :switchman_shards do |t|
t.string :name
t.string :database_server_id
t.boolean :default, :default => false, :null => false
t.text :settings
end
create_table "thumbnails", :force => true do |t|
t.integer "parent_id", :limit => 8
@ -2400,18 +2393,6 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_index "user_account_associations", ["account_id"], :name => "index_user_account_associations_on_account_id"
add_index :user_account_associations, [:user_id, :account_id], :unique => true
create_table :user_follows do |t|
t.integer :following_user_id, :limit => 8, :null => false
t.string :followed_item_type
t.integer :followed_item_id, :limit => 8, :null => false
t.timestamps null: true
end
# unique index of things a user is following, searchable by thing type
add_index :user_follows, [:following_user_id, :followed_item_type, :followed_item_id], :unique => true, :name => "index_user_follows_unique"
# the reverse index -- users who are following this thing
add_index :user_follows, [:followed_item_id, :followed_item_type], :name => "index_user_follows_inverse"
create_table "user_notes", :force => true do |t|
t.integer "user_id", :limit => 8
t.text "note"
@ -2517,6 +2498,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.text :bio
t.string :title
t.references :user, :limit => 8
end
create_table :user_profile_links do |t|
@ -2526,6 +2508,16 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.timestamps null: true
end
create_table :custom_data do |t|
t.text :data
t.string :namespace
t.references :user, :limit => 8
t.timestamps null: true
end
add_index :custom_data, [:user_id, :namespace],
name: 'index_custom_data_on_user_id_and_namespace',
unique: true
create_table "versions", :force => true do |t|
t.integer "versionable_id", :limit => 8
t.string "versionable_type"
@ -2587,7 +2579,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
t.text "url"
t.datetime "delayed_post_at"
t.boolean "protected_editing", :default => false
t.boolean "hide_from_students", :default => false
t.boolean "hide_from_students"
t.string "editing_roles"
t.integer "view_count", :default => 0
t.datetime "revised_at"
@ -2663,69 +2655,10 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
"UPDATE submissions SET workflow_state = 'graded' WHERE id = NEW.submission_id;"
end
create_trigger("collection_items_after_insert_row_tr", :generated => true, :compatibility => 1).
on("collection_items").
after(:insert) do |t|
t.where("NEW.workflow_state = 'active'") do
<<-SQL_ACTIONS
UPDATE collections
SET items_count = items_count + 1
WHERE id = NEW.collection_id;
SQL_ACTIONS
end
end
create_trigger("collection_items_after_update_row_tr", :generated => true, :compatibility => 1).
on("collection_items").
after(:update) do |t|
t.where("NEW.workflow_state <> OLD.workflow_state") do
<<-SQL_ACTIONS
UPDATE collections
SET items_count = items_count + CASE WHEN (NEW.workflow_state = 'active') THEN 1 ELSE -1 END
WHERE id = NEW.collection_id;
SQL_ACTIONS
end
end
create_trigger("collection_items_after_delete_row_tr", :generated => true, :compatibility => 1).
on("collection_items").
after(:delete) do |t|
t.where("OLD.workflow_state = 'active'") do
<<-SQL_ACTIONS
UPDATE collections
SET items_count = items_count - 1
WHERE id = OLD.collection_id;
SQL_ACTIONS
end
end
create_trigger("user_follows_after_insert_row_tr", :generated => true, :compatibility => 1).
on("user_follows").
after(:insert) do |t|
t.where("NEW.followed_item_type = 'Collection'") do
<<-SQL_ACTIONS
UPDATE collections
SET followers_count = followers_count + 1
WHERE id = NEW.followed_item_id;
SQL_ACTIONS
end
end
create_trigger("user_follows_after_delete_row_tr", :generated => true, :compatibility => 1).
on("user_follows").
after(:delete) do |t|
t.where("OLD.followed_item_type = 'Collection'") do
<<-SQL_ACTIONS
UPDATE collections
SET followers_count = followers_count - 1
WHERE id = OLD.followed_item_id;
SQL_ACTIONS
end
end
add_foreign_key :abstract_courses, :accounts
add_foreign_key :abstract_courses, :accounts, :column => :root_account_id
add_foreign_key :abstract_courses, :enrollment_terms
add_foreign_key :abstract_courses, :sis_batches
add_foreign_key :access_tokens, :users
add_foreign_key :account_authorization_configs, :accounts
add_foreign_key :account_notification_roles, :account_notifications
@ -2738,6 +2671,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :account_users, :users
add_foreign_key :accounts, :accounts, :column => :parent_account_id
add_foreign_key :accounts, :accounts, :column => :root_account_id
add_foreign_key :accounts, :sis_batches
add_foreign_key :alert_criteria, :alerts
add_foreign_key :assessment_requests, :rubric_associations
add_foreign_key :assessment_requests, :submissions, column: :asset_id
@ -2746,17 +2680,20 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :assignment_groups, :cloned_items
add_foreign_key :assignment_override_students, :assignment_overrides
add_foreign_key :assignment_override_students, :assignments
add_foreign_key :assignment_override_students, :quizzes
add_foreign_key :assignment_override_students, :users
add_foreign_key :assignment_overrides, :assignments
add_foreign_key :assignment_overrides, :quizzes
add_foreign_key :assignments, :cloned_items
add_foreign_key :assignments, :group_categories
add_foreign_key :attachments, :attachments, column: :root_attachment_id
add_foreign_key :calendar_events, :calendar_events, :column => :parent_calendar_event_id
add_foreign_key :calendar_events, :cloned_items
add_foreign_key :calendar_events, :users
add_foreign_key :collaborations, :users
add_foreign_key :collaborators, :collaborations
add_foreign_key :collaborators, :groups
add_foreign_key :collaborators, :users
add_foreign_key :collection_items, :collections
add_foreign_key :communication_channels, :access_tokens
add_foreign_key :communication_channels, :users
add_foreign_key :content_exports, :attachments
@ -2768,8 +2705,10 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :content_migrations, :attachments, column: :overview_attachment_id
add_foreign_key :content_migrations, :courses, :column => :source_course_id
add_foreign_key :content_migrations, :users
add_foreign_key :content_participations, :users
add_foreign_key :content_tags, :cloned_items
add_foreign_key :content_tags, :context_modules
add_foreign_key :content_tags, :learning_outcomes
add_foreign_key :context_external_tools, :cloned_items
add_foreign_key :context_module_progressions, :context_modules
add_foreign_key :context_module_progressions, :users
@ -2782,17 +2721,22 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :course_account_associations, :course_sections
add_foreign_key :course_account_associations, :courses
add_foreign_key :course_sections, :accounts, :column => :root_account_id
add_foreign_key :course_sections, :courses
add_foreign_key :course_sections, :courses, :column => :nonxlist_course_id
add_foreign_key :course_sections, :enrollment_terms
add_foreign_key :course_sections, :sis_batches
add_foreign_key :courses, :abstract_courses
add_foreign_key :courses, :accounts
add_foreign_key :courses, :accounts, :column => :root_account_id
add_foreign_key :courses, :courses, :column => :template_course_id
add_foreign_key :courses, :enrollment_terms
add_foreign_key :courses, :sis_batches
add_foreign_key :courses, :wikis
add_foreign_key :custom_gradebook_column_data, :custom_gradebook_columns
add_foreign_key :custom_gradebook_column_data, :users
add_foreign_key :custom_gradebook_columns, :courses, :dependent => true
add_foreign_key :data_exports, :users
add_foreign_key :delayed_messages, :communication_channels
add_foreign_key :delayed_messages, :notification_policies
add_foreign_key :discussion_entries, :attachments
add_foreign_key :discussion_entries, :discussion_entries, column: :parent_id
@ -2802,6 +2746,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :discussion_entries, :users, column: :editor_id
add_foreign_key :discussion_entry_participants, :discussion_entries
add_foreign_key :discussion_entry_participants, :users
add_foreign_key :discussion_topic_materialized_views, :discussion_topics
add_foreign_key :discussion_topic_participants, :discussion_topics
add_foreign_key :discussion_topic_participants, :users
add_foreign_key :discussion_topics, :assignments
@ -2810,13 +2755,16 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :discussion_topics, :cloned_items
add_foreign_key :discussion_topics, :discussion_topics, :column => :root_topic_id
add_foreign_key :discussion_topics, :external_feeds
add_foreign_key :discussion_topics, :group_categories
add_foreign_key :discussion_topics, :users
add_foreign_key :discussion_topics, :users, column: :editor_id
add_foreign_key :enrollment_dates_overrides, :enrollment_terms
add_foreign_key :enrollment_terms, :accounts, :column => :root_account_id
add_foreign_key :enrollment_terms, :sis_batches
add_foreign_key :enrollments, :accounts, :column => :root_account_id
add_foreign_key :enrollments, :course_sections
add_foreign_key :enrollments, :courses
add_foreign_key :enrollments, :sis_batches
add_foreign_key :enrollments, :users
add_foreign_key :enrollments, :users, column: :associated_user_id
add_foreign_key :eportfolio_categories, :eportfolios
@ -2831,10 +2779,12 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :folders, :folders, :column => :parent_folder_id
add_foreign_key :grading_standards, :users
add_foreign_key :group_memberships, :groups
add_foreign_key :group_memberships, :sis_batches
add_foreign_key :group_memberships, :users
add_foreign_key :groups, :accounts
add_foreign_key :groups, :accounts, :column => :root_account_id
add_foreign_key :groups, :group_categories
add_foreign_key :groups, :sis_batches
add_foreign_key :groups, :wikis
add_foreign_key :ignores, :users
add_foreign_key :learning_outcome_groups, :learning_outcome_groups
@ -2844,6 +2794,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :learning_outcome_results, :users
add_foreign_key :media_objects, :accounts, :column => :root_account_id
add_foreign_key :media_objects, :users
add_foreign_key :migration_issues, :content_migrations
add_foreign_key :notification_policies, :communication_channels
add_foreign_key :oauth_requests, :users
add_foreign_key :one_time_passwords, :users
@ -2852,6 +2803,7 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :page_views, :users, column: :real_user_id
add_foreign_key :profiles, :accounts, :column => 'root_account_id'
add_foreign_key :pseudonyms, :accounts
add_foreign_key :pseudonyms, :sis_batches
add_foreign_key :pseudonyms, :users
add_foreign_key :quiz_question_regrades, :quiz_questions
add_foreign_key :quiz_question_regrades, :quiz_regrades
@ -2859,11 +2811,14 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :quiz_regrades, :quizzes
add_foreign_key :quiz_regrades, :users
add_foreign_key :quiz_statistics, :quizzes
add_foreign_key :quiz_submissions, :quizzes
add_foreign_key :quiz_submissions, :users
add_foreign_key :quizzes, :assignments
add_foreign_key :quizzes, :cloned_items
add_foreign_key :report_snapshots, :accounts
add_foreign_key :role_overrides, :accounts, :column => :context_id
add_foreign_key :roles, :accounts
add_foreign_key :roles, :accounts, column: :root_account_id
add_foreign_key :rubric_assessments, :rubric_associations
add_foreign_key :rubric_assessments, :rubrics
add_foreign_key :rubric_assessments, :users
@ -2873,9 +2828,13 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :rubrics, :users
add_foreign_key :session_persistence_tokens, :pseudonyms
add_foreign_key :sis_batches, :enrollment_terms, :column => :batch_mode_term_id
add_foreign_key :sis_batches, :users
add_foreign_key :stream_item_instances, :users
add_foreign_key :submission_comment_participants, :users
add_foreign_key :submission_comments, :submissions
add_foreign_key :submission_comments, :users, column: :author_id
add_foreign_key :submission_comments, :users, column: :recipient_id
add_foreign_key :submissions, :assignments
add_foreign_key :submissions, :groups
add_foreign_key :submissions, :media_objects
add_foreign_key :submissions, :users
@ -2883,6 +2842,10 @@ class InitCanvasDb < ActiveRecord::Migration[4.2]
add_foreign_key :user_account_associations, :users
add_foreign_key :user_notes, :users
add_foreign_key :user_notes, :users, column: :created_by_id
add_foreign_key :user_observers, :users
add_foreign_key :user_observers, :users, column: :observer_id
add_foreign_key :user_profile_links, :user_profiles
add_foreign_key :user_profiles, :users
add_foreign_key :user_services, :users
add_foreign_key :web_conference_participants, :users
add_foreign_key :web_conference_participants, :web_conferences

View File

@ -41,7 +41,6 @@ class AddCassandraPageViewTables < ActiveRecord::Migration[4.2]
asset_type text,
controller text,
action text,
contributed boolean,
interaction_seconds double,
created_at timestamp,
updated_at timestamp,

View File

@ -61,7 +61,9 @@ class AddAuthenticationAuditorTables < ActiveRecord::Migration[4.2]
course_id bigint,
event_type text,
user_id bigint,
data text
data text,
event_source text,
sis_batch_id bigint
) #{compression_params}}
cassandra.execute %{

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2014 - 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 DeprecateHideFromStudentsOnWikiPages < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
change_column_default(:wiki_pages, :hide_from_students, nil)
DataFixup::DeprecateHideFromStudentsOnWikiPages.send_later_if_production_enqueue_args(:run, :priority => Delayed::LOW_PRIORITY, :max_attempts => 1)
end
def self.down
change_column_default(:wiki_pages, :hide_from_students, false)
end
end

View File

@ -1,38 +0,0 @@
#
# Copyright (C) 2014 - 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 DisallowNullOnCustomGradebookColumnColumns < ActiveRecord::Migration[4.2]
tag :predeploy
def self.allow_null(frd)
%w(position workflow_state course_id).each { |col|
change_column_null :custom_gradebook_columns, col, frd
}
%w(content user_id custom_gradebook_column_id).each { |col|
change_column_null :custom_gradebook_column_data, col, frd
}
end
def self.up
allow_null(false)
end
def self.down
allow_null(true)
end
end

View File

@ -1,38 +0,0 @@
#
# Copyright (C) 2014 - 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 AddDataExport < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
create_table :data_exports do |t|
t.integer :user_id, :limit => 8
t.integer :context_id, :limit => 8
t.string :context_type
t.string :workflow_state
t.datetime :created_at
t.datetime :updated_at
end
add_index :data_exports, [:context_id, :context_type]
add_index :data_exports, :user_id
add_foreign_key :data_exports, :users
end
def self.down
drop_table :data_exports
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2014 - 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 AddAttachmentRootAttachmentForeignKey < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
DataFixup::FixOrphanedAttachments.run
add_foreign_key :attachments, :attachments, column: :root_attachment_id, delay_validation: true
end
def self.down
remove_foreign_key :attachments, column: :root_attachment_id
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2014 - 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 DisallowNullOnTeacherNotesColumn < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
CustomGradebookColumn.where(teacher_notes: nil).update_all(teacher_notes: false)
change_column_null :custom_gradebook_columns, :teacher_notes, false
end
def self.down
change_column_null :custom_gradebook_columns, :teacher_notes, true
end
end

View File

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

View File

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

View File

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

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2014 - 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 EnrollmentsOnRootAccountAndCourse < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :enrollments, [:root_account_id, :course_id],
algorithm: :concurrently
end
def self.down
remove_index :enrollments, [:root_account_id, :course_id]
end
end

View File

@ -1,47 +0,0 @@
#
# Copyright (C) 2014 - 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 AddForeignKeys14 < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :assignment_override_students, :quizzes, delay_validation: true
add_foreign_key_if_not_exists :assignment_overrides, :quizzes, delay_validation: true
add_foreign_key_if_not_exists :collaborators, :groups, delay_validation: true
add_foreign_key_if_not_exists :content_participations, :users, delay_validation: true
add_foreign_key_if_not_exists :content_tags, :learning_outcomes, delay_validation: true
add_foreign_key_if_not_exists :context_module_progressions, :context_modules, delay_validation: true
add_foreign_key_if_not_exists :course_sections, :courses, delay_validation: true
add_foreign_key_if_not_exists :delayed_messages, :communication_channels, delay_validation: true
add_foreign_key_if_not_exists :discussion_topic_materialized_views, :discussion_topics, delay_validation: true
add_foreign_key_if_not_exists :migration_issues, :content_migrations, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :assignment_override_students, :quizzes
remove_foreign_key_if_exists :assignment_overrides, :quizzes
remove_foreign_key_if_exists :collaborators, :groups
remove_foreign_key_if_exists :content_participations, :users
remove_foreign_key_if_exists :content_tags, :learning_outcomes
remove_foreign_key_if_exists :context_module_progressions, :context_modules
remove_foreign_key_if_exists :course_sections, :courses
remove_foreign_key_if_exists :delayed_messages, :communication_channels
remove_foreign_key_if_exists :discussion_topic_materialized_views, :discussion_topics
remove_foreign_key_if_exists :migration_issues, :content_migrations
end
end

View File

@ -1,49 +0,0 @@
#
# Copyright (C) 2014 - 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 AddForeignKeys15 < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :quiz_submissions, :quizzes, delay_validation: true
add_foreign_key_if_not_exists :quizzes, :assignments, delay_validation: true
add_foreign_key_if_not_exists :roles, :accounts, column: :root_account_id, delay_validation: true
add_foreign_key_if_not_exists :stream_item_instances, :users, delay_validation: true
add_foreign_key_if_not_exists :submission_comments, :submissions, delay_validation: true
add_foreign_key_if_not_exists :submissions, :assignments, delay_validation: true
add_foreign_key_if_not_exists :user_observers, :users, column: :observer_id, delay_validation: true
add_foreign_key_if_not_exists :user_observers, :users, delay_validation: true
add_foreign_key_if_not_exists :user_profile_links, :user_profiles, delay_validation: true
add_foreign_key_if_not_exists :user_profiles, :users, delay_validation: true
add_foreign_key_if_not_exists :web_conference_participants, :web_conferences, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :quiz_submissions, :quizzes
remove_foreign_key_if_exists :quizzes, :assignments
remove_foreign_key_if_exists :roles, :accounts, column: :root_account_id
remove_foreign_key_if_exists :stream_item_instances, :users
remove_foreign_key_if_exists :submission_comments, :submissions
remove_foreign_key_if_exists :submissions, :assignments
remove_foreign_key_if_exists :user_observers, :users, column: :observer_id
remove_foreign_key_if_exists :user_observers, :users
remove_foreign_key_if_exists :user_profile_links, :user_profiles
remove_foreign_key_if_exists :user_profiles, :users
remove_foreign_key_if_exists :web_conference_participants, :web_conferences
end
end

View File

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

View File

@ -1,164 +0,0 @@
#
# Copyright (C) 2014 - 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 RemoveCanvinterestTables < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
drop_trigger("collection_items_after_insert_row_tr", "collection_items", :generated => true)
drop_trigger("collection_items_after_insert_row_when_new_workflow_state_ac_tr", "collection_items", :generated => true)
drop_trigger("collection_items_after_update_row_tr", "collection_items", :generated => true)
drop_trigger("collection_items_after_update_row_when_new_workflow_state_ol_tr", "collection_items", :generated => true)
drop_trigger("collection_items_after_delete_row_tr", "collection_items", :generated => true)
drop_trigger("collection_items_after_delete_row_when_old_workflow_state_ac_tr", "collection_items", :generated => true)
drop_trigger("user_follows_after_insert_row_tr", "user_follows", :generated => true)
drop_trigger("user_follows_after_insert_row_when_new_followed_item_type_co_tr", "user_follows", :generated => true)
drop_trigger("user_follows_after_delete_row_tr", "user_follows", :generated => true)
drop_trigger("user_follows_after_delete_row_when_old_followed_item_type_co_tr", "user_follows", :generated => true)
drop_table :user_follows
drop_table :collection_item_upvotes
drop_table :collection_item_datas
drop_table :collection_items
drop_table :collections
end
def self.down
create_table "user_follows", :force => true do |t|
t.integer "following_user_id", :limit => 8, :null => false
t.string "followed_item_type"
t.integer "followed_item_id", :limit => 8, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "user_follows", ["followed_item_id", "followed_item_type"], :name => "index_user_follows_inverse"
add_index "user_follows", ["following_user_id", "followed_item_type", "followed_item_id"], :name => "index_user_follows_unique", :unique => true
create_table "collection_item_upvotes", :force => true do |t|
t.integer "collection_item_data_id", :limit => 8, :null => false
t.integer "user_id", :limit => 8, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "collection_item_upvotes", ["collection_item_data_id", "user_id"], :name => "index_collection_item_upvotes_join", :unique => true
create_table "collection_item_datas", :force => true do |t|
t.string "item_type"
t.text "link_url", :null => false
t.integer "root_item_id", :limit => 8
t.integer "post_count", :default => 0
t.integer "upvote_count", :default => 0
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "image_pending"
t.integer "image_attachment_id", :limit => 8
t.text "image_url"
t.text "html_preview"
t.string "title"
t.text "description"
end
create_table "collection_items", :force => true do |t|
t.integer "collection_item_data_id", :limit => 8, :null => false
t.integer "collection_id", :limit => 8, :null => false
t.string "workflow_state", :null => false
t.text "user_comment"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id", :limit => 8, :null => false
end
add_index "collection_items", ["collection_id", "workflow_state"], :name => "index_collection_items_on_collection_id_and_workflow_state"
add_index "collection_items", ["collection_item_data_id", "workflow_state"], :name => "index_collection_items_on_data_id"
create_table "collections", :force => true do |t|
t.string "name"
t.string "visibility", :default => "private"
t.string "context_type", :null => false
t.integer "context_id", :limit => 8, :null => false
t.string "workflow_state", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "followers_count", :default => 0
t.integer "items_count", :default => 0
end
add_index "collections", ["context_id", "context_type", "workflow_state", "visibility"], :name => "index_collections_for_finding"
create_trigger("user_follows_after_insert_row_tr", :generated => true, :compatibility => 1).
on("user_follows").
after(:insert) do |t|
t.where("NEW.followed_item_type = 'Collection'") do
<<-SQL_ACTIONS
UPDATE collections
SET followers_count = followers_count + 1
WHERE id = NEW.followed_item_id;
SQL_ACTIONS
end
end
create_trigger("user_follows_after_delete_row_tr", :generated => true, :compatibility => 1).
on("user_follows").
after(:delete) do |t|
t.where("OLD.followed_item_type = 'Collection'") do
<<-SQL_ACTIONS
UPDATE collections
SET followers_count = followers_count - 1
WHERE id = OLD.followed_item_id;
SQL_ACTIONS
end
end
create_trigger("collection_items_after_insert_row_tr", :generated => true, :compatibility => 1).
on("collection_items").
after(:insert) do |t|
t.where("NEW.workflow_state = 'active'") do
<<-SQL_ACTIONS
UPDATE collections
SET items_count = items_count + 1
WHERE id = NEW.collection_id;
SQL_ACTIONS
end
end
create_trigger("collection_items_after_update_row_tr", :generated => true, :compatibility => 1).
on("collection_items").
after(:update) do |t|
t.where("NEW.workflow_state <> OLD.workflow_state") do
<<-SQL_ACTIONS
UPDATE collections
SET items_count = items_count + CASE WHEN (NEW.workflow_state = 'active') THEN 1 ELSE -1 END
WHERE id = NEW.collection_id;
SQL_ACTIONS
end
end
create_trigger("collection_items_after_delete_row_tr", :generated => true, :compatibility => 1).
on("collection_items").
after(:delete) do |t|
t.where("OLD.workflow_state = 'active'") do
<<-SQL_ACTIONS
UPDATE collections
SET items_count = items_count - 1
WHERE id = OLD.collection_id;
SQL_ACTIONS
end
end
end
end

View File

@ -1,39 +0,0 @@
#
# Copyright (C) 2014 - 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 comes from switchman (originally 20130328212039)
class CreateSwitchmanShards < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
unless table_exists?('switchman_shards')
create_table :switchman_shards do |t|
t.string :name
t.string :database_server_id
t.boolean :default, :default => false, :null => false
end
end
unless column_exists?(:switchman_shards, :settings)
add_column :switchman_shards, :settings, :text
end
end
def self.down
drop_table :switchman_shards
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2014 - 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 AddLockdownBrowserMonitorSettings < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :quizzes, :require_lockdown_browser_monitor, :boolean
add_column :quizzes, :lockdown_browser_monitor_data, :text
end
def self.down
remove_column :quizzes, :require_lockdown_browser_monitor
remove_column :quizzes, :lockdown_browser_monitor_data
end
end

View File

@ -1,32 +0,0 @@
#
# Copyright (C) 2014 - 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 AddIndexOnAssetUserAccess < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :asset_user_accesses, [:context_id, :context_type, :user_id, :updated_at],
name: 'index_asset_user_accesses_on_ci_ct_ui_ua', algorithm: :concurrently
remove_index :asset_user_accesses, [:context_id, :context_type]
end
def self.down
add_index :asset_user_accesses, [:context_id, :context_type], algorithm: :concurrently
remove_index :asset_user_accesses, name: 'index_asset_user_accesses_on_ci_ct_ui_ua'
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2014 - 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 RemovePageViewsContributed < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
remove_column :page_views, :contributed
end
def self.down
add_column :page_views, :contributed, :boolean
end
end

View File

@ -1,41 +0,0 @@
#
# Copyright (C) 2014 - 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 RemoveCassandraPageViewsContributed < ActiveRecord::Migration[4.2]
tag :postdeploy
include Canvas::Cassandra::Migration
def self.cassandra_cluster
'page_views'
end
def self.runnable?
# cassandra 1.2.x doesn't support dropping columns, oddly enough
return false unless super
server_version = cassandra.db.connection.describe_version()
server_version < '19.35.0' || server_version >= '19.39.0'
end
def self.up
cassandra.execute %{ ALTER TABLE page_views DROP contributed; }
end
def self.down
cassandra.execute %{ ALTER TABLE page_views ADD contributed boolean; }
end
end

View File

@ -1,65 +0,0 @@
#
# Copyright (C) 2014 - 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 AddUniqueIndexOnEnrollments < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
DataFixup::RemoveDuplicateEnrollments.run
if connection.adapter_name == 'PostgreSQL'
add_index :enrollments,
[:user_id, :type, :role_name, :course_section_id, :associated_user_id],
where: "associated_user_id IS NOT NULL AND role_name IS NOT NULL",
name: 'index_enrollments_on_user_type_role_section_associated_user',
unique: true,
algorithm: :concurrently
add_index :enrollments,
[:user_id, :type, :role_name, :course_section_id],
where: "role_name IS NOT NULL AND associated_user_id IS NULL ",
name: 'index_enrollments_on_user_type_role_section',
unique: true,
algorithm: :concurrently
add_index :enrollments,
[:user_id, :type, :course_section_id, :associated_user_id],
where: "associated_user_id IS NOT NULL AND role_name IS NULL",
name: 'index_enrollments_on_user_type_section_associated_user',
unique: true,
algorithm: :concurrently
add_index :enrollments,
[:user_id, :type, :course_section_id],
where: "associated_user_id IS NULL AND role_name IS NULL",
unique: true,
algorithm: :concurrently
else
add_index :enrollments,
[:user_id, :type, :role_name, :course_section_id, :associated_user_id],
name: 'index_enrollments_on_user_type_role_section_associated_user',
unique: true,
algorithm: :concurrently
end
end
def self.down
remove_index :enrollments, name: 'index_enrollments_on_user_type_role_section_associated_user'
if connection.adapter_name == 'PostgreSQL'
remove_index :enrollments, name: 'index_enrollments_on_user_type_role_section'
remove_index :enrollments, name: 'index_enrollments_on_user_type_section_associated_user'
remove_index :enrollments, [:user_id, :type, :course_section_id]
end
end
end

View File

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

View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2014 - 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 AddUserToSisBatches < ActiveRecord::Migration[4.2]
tag :predeploy
disable_ddl_transaction!
def self.up
add_column :sis_batches, :user_id, :integer, :limit => 8
add_foreign_key :sis_batches, :users, delay_validation: true
end
def self.down
remove_foreign_key :sis_batches, :users
remove_column :sis_batches, :user_id
end
end

View File

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

View File

@ -1,33 +0,0 @@
#
# Copyright (C) 2014 - 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 CreateCustomData < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
create_table :custom_data do |t|
t.text :data
t.string :namespace
t.references :user, :limit => 8
t.timestamps null: true
end
end
def self.down
drop_table :custom_data
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2014 - 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 AddLockVersionOnContextModuleProgressions < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :context_module_progressions, :lock_version, :integer
change_column_default :context_module_progressions, :lock_version, 0
end
def self.down
remove_column :context_module_progressions, :lock_version
end
end

View File

@ -1,45 +0,0 @@
#
# Copyright (C) 2014 - 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 AddForeignKeys16 < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_foreign_key_if_not_exists :pseudonyms, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :accounts, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :enrollment_terms, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :abstract_courses, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :courses, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :course_sections, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :enrollments, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :groups, :sis_batches, delay_validation: true
add_foreign_key_if_not_exists :group_memberships, :sis_batches, delay_validation: true
end
def self.down
remove_foreign_key_if_exists :pseudonyms, :sis_batches
remove_foreign_key_if_exists :accounts, :sis_batches
remove_foreign_key_if_exists :enrollment_terms, :sis_batches
remove_foreign_key_if_exists :abstract_courses, :sis_batches
remove_foreign_key_if_exists :courses, :sis_batches
remove_foreign_key_if_exists :course_sections, :sis_batches
remove_foreign_key_if_exists :enrollments, :sis_batches
remove_foreign_key_if_exists :groups, :sis_batches
remove_foreign_key_if_exists :group_memberships, :sis_batches
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2014 - 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 AddUniqueIndexOnCustomData < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_index :custom_data, [:user_id, :namespace],
name: 'index_custom_data_on_user_id_and_namespace',
unique: true
end
def self.down
remove_index :custom_data, name: 'index_custom_data_on_user_id_and_namespace'
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2014 - 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 AddIndexMessagesOnSentAt < ActiveRecord::Migration[4.2]
tag :postdeploy
disable_ddl_transaction!
def self.up
add_index :messages, :sent_at, algorithm: :concurrently, where: "sent_at IS NOT NULL"
end
def self.down
remove_index :messages, :sent_at
end
end

View File

@ -1,32 +0,0 @@
#
# Copyright (C) 2014 - 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 DisallowNullOnDataExportColumns < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
%w(user_id context_id context_type workflow_state).each do |c|
change_column_null :data_exports, c, false
end
end
def self.down
%w(user_id context_id context_type workflow_state).each do |c|
change_column_null :data_exports, c, true
end
end
end

View File

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

View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2014 - 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 ConvertHighContrastSettingToFeatureFlag < ActiveRecord::Migration[4.2]
tag :postdeploy
def self.up
DataFixup::ConvertHighContrastSettingToFeatureFlag.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) 2014 - 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 AddAssignmentPostColumns < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :assignments, :post_to_sis, :boolean
add_column :assignments, :integration_id, :string
# We used to add an index on integration_id here, but decided not
# to add it at all after it'd already been migrated in some envs
end
def self.down
if index_exists?(:assignments, :integration_id)
remove_index :assignments, :integration_id
end
remove_column :assignments, :post_to_sis
remove_column :assignments, :integration_id
end
end

View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2014 - 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 AddGroupCategoryIdToDiscussionTopic < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_column :discussion_topics, :group_category_id, :integer, :limit => 8
add_foreign_key :discussion_topics, :group_categories
end
def self.down
remove_foreign_key :discussion_topics, :group_categories
remove_column :discussion_topics, :group_category_id
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2014 - 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 AddTimestampsToCrocodocDocuments < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
add_timestamps(:crocodoc_documents, null: true)
end
def self.down
remove_column :crocodoc_documents, :created_at
remove_column :crocodoc_documents, :updated_at
end
end

View File

@ -1,34 +0,0 @@
#
# Copyright (C) 2014 - 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 LengthenStringColumns < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
change_column :context_external_tools, :consumer_key, :text
change_column :context_external_tools, :shared_secret, :text
change_column :migration_issues, :fix_issue_html_url, :text
change_column :submission_comments, :attachment_ids, :text
end
def self.down
change_column :context_external_tools, :consumer_key, :string, :limit => 255
change_column :context_external_tools, :shared_secret, :string, :limit => 255
change_column :migration_issues, :fix_issue_html_url, :string, :limit => 255
change_column :submission_comments, :attachment_ids, :string, :limit => 255
end
end

View File

@ -1,36 +0,0 @@
#
# Copyright (C) 2014 - 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 AddCassandraEventSourceToCoursesAuditor < ActiveRecord::Migration[4.2]
tag :predeploy
include Canvas::Cassandra::Migration
def self.cassandra_cluster
'auditors'
end
def self.up
cassandra.execute %{ ALTER TABLE courses ADD event_source text; }
cassandra.execute %{ ALTER TABLE courses ADD sis_batch_id bigint; }
end
def self.down
cassandra.execute %{ ALTER TABLE courses DROP event_source; }
cassandra.execute %{ ALTER TABLE courses DROP sis_batch_id; }
end
end

View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2014 - 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 ConvertHighContrastSettingToFeatureFlag
def self.run
User.where("preferences LIKE '%high_contrast%'").where("workflow_state<>'deleted'").find_each do |user|
if user.preferences[:enabled_theme] == 'high_contrast'
user.enable_feature!(:high_contrast)
end
end
end
end
end

View File

@ -1,26 +0,0 @@
#
# Copyright (C) 2014 - 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::DeprecateHideFromStudentsOnWikiPages
def self.run
WikiPage.find_ids_in_ranges do |min_id, max_id|
WikiPage.where(id: min_id..max_id)
.where("hide_from_students IS NOT NULL")
.update_all("hide_from_students=NULL, workflow_state=CASE WHEN hide_from_students AND workflow_state='active' THEN 'unpublished' ELSE workflow_state END")
end
end
end

View File

@ -1,110 +0,0 @@
#
# Copyright (C) 2014 - 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
class FixOrphanedAttachments
def self.run
@new_roots = Set.new
Shackles.activate(:slave) do
scope = Attachment.
where("root_attachment_id IS NOT NULL AND
NOT EXISTS (SELECT id
FROM #{Attachment.quoted_table_name} ra
WHERE ra.id = attachments.root_attachment_id)")
create_users if scope.exists?
scope.find_each(start: 0) do |a|
next if @new_roots.include? a.root_attachment_id
fix_orphaned_file(a)
@new_roots << a.root_attachment_id
end
end
end
def self.create_users
Shackles.activate(:master) do
@deleted_user = User.create(name: 'rescued attachments')
@deleted_user.destroy
@broken_user = User.create(name: 'broken attachments')
@broken_user.destroy
end
end
def self.other_namespace(attachment)
account_id = attachment.namespace.sub('account_', '').to_i
if account_id.to_s.length > 8
namespace_account_id = Account.where(id: account_id).first.try(:local_id)
else
namespace_account_id = attachment.shard.global_id_for(account_id)
end
"account_#{namespace_account_id}"
end
def self.s3_save(rescued_orphan, ns)
if rescued_orphan.s3object.exists?
rescued_orphan.save!
rescued_orphan.namespace = ns
finalize_attachment(rescued_orphan)
else
ns = rescued_orphan.namespace = other_namespace(rescued_orphan)
if rescued_orphan.s3object.exists?
rescued_orphan.save!
rescued_orphan.namespace = ns
finalize_attachment(rescued_orphan)
else
rescued_orphan.context_id = @broken_user.id
finalize_attachment(rescued_orphan)
end
end
end
def self.local_storage_save(rescued_orphan)
if File.exist? rescued_orphan.full_filename
finalize_attachment(rescued_orphan)
else
rescued_orphan.context_id = @broken_user.id
finalize_attachment(rescued_orphan)
end
end
def self.finalize_attachment(attachment)
attachment.file_state = 'deleted'
attachment.save!
end
def self.fix_orphaned_file(attachment)
rescued_orphan = Attachment.new
rescued_orphan.id = attachment.root_attachment_id unless attachment.root_attachment_id > Shard::IDS_PER_SHARD
rescued_orphan.context_type = 'User'
rescued_orphan.context_id = @deleted_user.id
rescued_orphan.size = attachment.size
rescued_orphan.content_type = attachment.content_type
rescued_orphan.filename = attachment.filename || "none"
rescued_orphan.display_name = attachment.display_name
rescued_orphan.file_state = 'deleted'
rescued_orphan.md5 = attachment.md5
ns = rescued_orphan.namespace = attachment.namespace
Shackles.activate(:master) do
Attachment.s3_storage? ? s3_save(rescued_orphan, ns) : local_storage_save(rescued_orphan)
if rescued_orphan.id != attachment.root_attachment_id
Attachment.where(root_attachment_id: attachment.root_attachment_id).update_all(root_attachment_id: rescued_orphan.id)
end
end
end
end
end

View File

@ -1,56 +0,0 @@
#
# Copyright (C) 2014 - 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::RemoveDuplicateEnrollments
def self.run
recalulate_grades_for = Set.new
Enrollment.
select("user_id, type, role_name AS role_name_unhidden, course_section_id, associated_user_id").
group("user_id, type, role_name, course_section_id, associated_user_id").
having("COUNT(*) > 1").find_each do |e|
scope = Enrollment.
where(user_id: e.user_id,
type: e.type,
role_name: e.role_name_unhidden,
course_section_id: e.course_section_id,
associated_user_id: e.associated_user_id)
# prefer active enrollments to have no impact to the end user.
# then prefer enrollments that were created by sis imports
# then just keep the newest one.
keeper = scope.order(Arel.sql("CASE WHEN workflow_state='active' THEN 1
WHEN workflow_state='invited' THEN 2
WHEN workflow_state='creation_pending' THEN 3
WHEN sis_batch_id IS NOT NULL THEN 4
WHEN workflow_state='completed' THEN 5
WHEN workflow_state='rejected' THEN 6
WHEN workflow_state='inactive' THEN 7
WHEN workflow_state='deleted' THEN 8
ELSE 9
END, sis_batch_id DESC, updated_at DESC")).first
# delete all duplicate
scope.where("id<>?", keeper).delete_all
recalulate_grades_for << keeper.user_id if keeper.type == 'StudentEnrollment'
end
recalulate_grades_for.each do |u|
Enrollment.send_later_if_production(:recompute_final_scores, u)
end
end
end

View File

@ -1,29 +0,0 @@
#
# Copyright (C) 2014 - 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 SanitizeCompletionRequirements
def self.run
ContextModule.
where("completion_requirements LIKE '%min\_score%' OR completion_requirements LIKE '%max\_score%'").
find_each do |cm|
cm.completion_requirements = cm.completion_requirements
cm.save!
end
end
end
end

View File

@ -1,37 +0,0 @@
#
# Copyright (C) 2014 - 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 'sanitize'
module DataFixup
module SanitizeEportfolios
def self.run
config = CanvasSanitize::SANITIZE
EportfolioEntry.
where("content LIKE '%rich\_text%' OR content LIKE '%html%'").
find_each do |entry|
next unless entry.content.is_a?(Array)
entry.content.each do |obj|
next unless obj.is_a?(Hash)
next unless ['rich_text', 'html'].include?(obj[:section_type])
obj[:content] = Sanitize.clean(obj[:content] || '', config).strip
end
entry.save!
end
end
end
end