make it easy for add_column_and_fk helper to be idempotent
Change-Id: I4d5c8d85a7cd0a7aa2c84f3278bfcecef0425398 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/239559 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Simon Williams <simon@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
5c3e5df00f
commit
d85aa95894
|
@ -22,7 +22,7 @@ class AddRootAccountIdToWikis < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :wikis, :root_account_id, :accounts
|
||||
add_column_and_fk :wikis, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :wikis, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToWikiPages < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :wiki_pages, :root_account_id, :accounts
|
||||
add_column_and_fk :wiki_pages, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :wiki_pages, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToRubrics < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :rubrics, :root_account_id, :accounts
|
||||
add_column_and_fk :rubrics, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :rubrics, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToRubricAssociations < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :rubric_associations, :root_account_id, :accounts
|
||||
add_column_and_fk :rubric_associations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :rubric_associations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToRubricAssessments < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :rubric_assessments, :root_account_id, :accounts
|
||||
add_column_and_fk :rubric_assessments, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :rubric_assessments, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToMasterCoursesMigrationResults < ActiveRecord::Migration[
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :master_courses_migration_results, :root_account_id, :accounts
|
||||
add_column_and_fk :master_courses_migration_results, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :master_courses_migration_results, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToMasterCoursesMasterTemplates < ActiveRecord::Migration[5
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :master_courses_master_templates, :root_account_id, :accounts
|
||||
add_column_and_fk :master_courses_master_templates, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :master_courses_master_templates, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToMasterCoursesMasterContentTags < ActiveRecord::Migration
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :master_courses_master_content_tags, :root_account_id, :accounts
|
||||
add_column_and_fk :master_courses_master_content_tags, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :master_courses_master_content_tags, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToQuizzes < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :quizzes, :root_account_id, :accounts
|
||||
add_column_and_fk :quizzes, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :quizzes, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToQuizQuestions < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :quiz_questions, :root_account_id, :accounts
|
||||
add_column_and_fk :quiz_questions, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :quiz_questions, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToQuizGroups < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :quiz_groups, :root_account_id, :accounts
|
||||
add_column_and_fk :quiz_groups, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :quiz_groups, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToQuizSubmissions < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :quiz_submissions, :root_account_id, :accounts
|
||||
add_column_and_fk :quiz_submissions, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :quiz_submissions, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToAssessmentQuestionBanks < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :assessment_question_banks, :root_account_id, :accounts
|
||||
add_column_and_fk :assessment_question_banks, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :assessment_question_banks, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToAssessmentQuestions < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :assessment_questions, :root_account_id, :accounts
|
||||
add_column_and_fk :assessment_questions, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :assessment_questions, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ class AddRootAccountIdToMasterCoursesChildSubscriptions < ActiveRecord::Migratio
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :master_courses_child_subscriptions, :root_account_id, :accounts
|
||||
add_column_and_fk :master_courses_child_subscriptions, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :master_courses_child_subscriptions, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :master_courses_child_subscriptions, :root_account_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToContentTags < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :content_tags, :root_account_id, :accounts
|
||||
add_column_and_fk :content_tags, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :content_tags, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToDeveloperKeyAccountBindings < ActiveRecord::Migration[5.
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :developer_key_account_bindings, :root_account_id, :accounts
|
||||
add_column_and_fk :developer_key_account_bindings, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :developer_key_account_bindings, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToDeveloperKeys < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :developer_keys, :root_account_id, :accounts
|
||||
add_column_and_fk :developer_keys, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :developer_keys, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToLtiResourceLinks < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :lti_resource_links, :root_account_id, :accounts
|
||||
add_column_and_fk :lti_resource_links, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :lti_resource_links, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToLtiResults < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :lti_results, :root_account_id, :accounts
|
||||
add_column_and_fk :lti_results, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :lti_results, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddRootAccountIdToOriginalityReports < ActiveRecord::Migration[5.2]
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def up
|
||||
add_column_and_fk :originality_reports, :root_account_id, :accounts
|
||||
add_column_and_fk :originality_reports, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :originality_reports, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToMasterCoursesChildContentTags < ActiveRecord::Migration[
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :master_courses_child_content_tags, :root_account_id, :accounts
|
||||
add_column_and_fk :master_courses_child_content_tags, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :master_courses_child_content_tags, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToDiscussionTopicParticipants < ActiveRecord::Migration[5.
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :discussion_topic_participants, :root_account_id, :accounts
|
||||
add_column_and_fk :discussion_topic_participants, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :discussion_topic_participants, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToCourseAccountAssociations < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :course_account_associations, :root_account_id, :accounts
|
||||
add_column_and_fk :course_account_associations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :course_account_associations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToContextModules < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :context_modules, :root_account_id, :accounts
|
||||
add_column_and_fk :context_modules, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :context_modules, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToContextModuleProgressions < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :context_module_progressions, :root_account_id, :accounts
|
||||
add_column_and_fk :context_module_progressions, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :context_module_progressions, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToContentMigrations < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :content_migrations, :root_account_id, :accounts
|
||||
add_column_and_fk :content_migrations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :content_migrations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,6 @@ class AddNotificationPolicyOverideToDelayedMessage < ActiveRecord::Migration[5.2
|
|||
include MigrationHelpers::AddColumnAndFk
|
||||
|
||||
def change
|
||||
add_column_and_fk :delayed_messages, :notification_policy_override_id, :notification_policy_overrides
|
||||
add_column_and_fk :delayed_messages, :notification_policy_override_id, :notification_policy_overrides, if_not_exists: true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAttachmentAssociations < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :attachment_associations, :root_account_id, :accounts
|
||||
add_column_and_fk :attachment_associations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :attachment_associations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAssignmentOverrideStudents < ActiveRecord::Migration[5.2
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :assignment_override_students, :root_account_id, :accounts
|
||||
add_column_and_fk :assignment_override_students, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :assignment_override_students, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAssignmentOverrides < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :assignment_overrides, :root_account_id, :accounts
|
||||
add_column_and_fk :assignment_overrides, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :assignment_overrides, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAssignmentGroups < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :assignment_groups, :root_account_id, :accounts
|
||||
add_column_and_fk :assignment_groups, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :assignment_groups, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountToSubmissionVersions < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :submission_versions, :root_account_id, :accounts
|
||||
add_column_and_fk :submission_versions, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :submission_versions, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountToSubmissionComments < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :submission_comments, :root_account_id, :accounts
|
||||
add_column_and_fk :submission_comments, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :submission_comments, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToScoreStatistics < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :score_statistics, :root_account_id, :accounts
|
||||
add_column_and_fk :score_statistics, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :score_statistics, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToScores < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :scores, :root_account_id, :accounts
|
||||
add_column_and_fk :scores, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :scores, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToGradingPeriods < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :grading_periods, :root_account_id, :accounts
|
||||
add_column_and_fk :grading_periods, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :grading_periods, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class AddRootAccountIdToPostPolicies < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :post_policies, :root_account_id, :accounts
|
||||
add_column_and_fk :post_policies, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :post_policies, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class AddRootAccountIdToLatePolicies < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :late_policies, :root_account_id, :accounts
|
||||
add_column_and_fk :late_policies, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :late_policies, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToGradingStandards < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :grading_standards, :root_account_id, :accounts
|
||||
add_column_and_fk :grading_standards, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :grading_standards, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToCustomGradebookColumns < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :custom_gradebook_columns, :root_account_id, :accounts
|
||||
add_column_and_fk :custom_gradebook_columns, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :custom_gradebook_columns, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToLearningOutcomeGroup < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :learning_outcome_groups, :root_account_id, :accounts
|
||||
add_column_and_fk :learning_outcome_groups, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :learning_outcome_groups, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToCustomGradebookColumnData < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :custom_gradebook_column_data, :root_account_id, :accounts
|
||||
add_column_and_fk :custom_gradebook_column_data, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :custom_gradebook_column_data, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToConversations < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :conversations, :root_account_id, :accounts
|
||||
add_column_and_fk :conversations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :conversations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToConversationParticipants < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :conversation_participants, :root_account_id, :accounts
|
||||
add_column_and_fk :conversation_participants, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :conversation_participants, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToMasterCoursesMasterMigrations < ActiveRecord::Migration[
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :master_courses_master_migrations, :root_account_id, :accounts
|
||||
add_column_and_fk :master_courses_master_migrations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :master_courses_master_migrations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToLearningOutcomes < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :learning_outcomes, :root_account_id, :accounts
|
||||
add_column_and_fk :learning_outcomes, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :learning_outcomes, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToLearningOutcomeQuestionResults < ActiveRecord::Migration
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :learning_outcome_question_results, :root_account_id, :accounts
|
||||
add_column_and_fk :learning_outcome_question_results, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :learning_outcome_question_results, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToLearningOutcomeResults < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :learning_outcome_results, :root_account_id, :accounts
|
||||
add_column_and_fk :learning_outcome_results, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :learning_outcome_results, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToOutcomeProficiencies < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :outcome_proficiencies, :root_account_id, :accounts
|
||||
add_column_and_fk :outcome_proficiencies, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :outcome_proficiencies, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToOutcomeProficiencyRatings < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :outcome_proficiency_ratings, :root_account_id, :accounts
|
||||
add_column_and_fk :outcome_proficiency_ratings, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :outcome_proficiency_ratings, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAccountUsers < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :account_users, :root_account_id, :accounts
|
||||
add_column_and_fk :account_users, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :account_users, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToEnrollmentStates < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :enrollment_states, :root_account_id, :accounts
|
||||
add_column_and_fk :enrollment_states, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :enrollment_states, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToGroupMemberships < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :group_memberships, :root_account_id, :accounts
|
||||
add_column_and_fk :group_memberships, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :group_memberships, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToRoleOverrides < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :role_overrides, :root_account_id, :accounts
|
||||
add_column_and_fk :role_overrides, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :role_overrides, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAccessTokens < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :access_tokens, :root_account_id, :accounts
|
||||
add_column_and_fk :access_tokens, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :access_tokens, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToUserAccountAssociations < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :user_account_associations, :root_account_id, :accounts
|
||||
add_column_and_fk :user_account_associations, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :user_account_associations, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToDiscussionEntries < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :discussion_entries, :root_account_id, :accounts
|
||||
add_column_and_fk :discussion_entries, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :discussion_entries, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRealUserIdToAccessToken < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :access_tokens, :real_user_id, :users
|
||||
add_column_and_fk :access_tokens, :real_user_id, :users, if_not_exists: true
|
||||
add_index :access_tokens, :real_user_id, algorithm: :concurrently, where: "real_user_id IS NOT NULL"
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAssetUserAccesses < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :asset_user_accesses, :root_account_id, :accounts
|
||||
add_column_and_fk :asset_user_accesses, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :asset_user_accesses, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToAttachments < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :attachments, :root_account_id, :accounts
|
||||
add_column_and_fk :attachments, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :attachments, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToContentShares < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :content_shares, :root_account_id, :accounts
|
||||
add_column_and_fk :content_shares, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :content_shares, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToUserNotes < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :user_notes, :root_account_id, :accounts
|
||||
add_column_and_fk :user_notes, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :user_notes, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToCalendarEvents < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :calendar_events, :root_account_id, :accounts
|
||||
add_column_and_fk :calendar_events, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :calendar_events, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToFolders < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :folders, :root_account_id, :accounts
|
||||
add_column_and_fk :folders, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :folders, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToCommunicationChannels < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :communication_channels, :root_account_id, :accounts
|
||||
add_column_and_fk :communication_channels, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :communication_channels, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToConversationMessages < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :conversation_messages, :root_account_id, :accounts
|
||||
add_column_and_fk :conversation_messages, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :conversation_messages, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToConversationMessageParticipants < ActiveRecord::Migratio
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :conversation_message_participants, :root_account_id, :accounts
|
||||
add_column_and_fk :conversation_message_participants, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :conversation_message_participants, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToFavorites < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :favorites, :root_account_id, :accounts
|
||||
add_column_and_fk :favorites, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :favorites, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToDiscussionTopics < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :discussion_topics, :root_account_id, :accounts
|
||||
add_column_and_fk :discussion_topics, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :discussion_topics, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ class AddRootAccountIdToDiscussionEntryParticipants < ActiveRecord::Migration[5.
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :discussion_entry_participants, :root_account_id, :accounts
|
||||
add_column_and_fk :discussion_entry_participants, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :discussion_entry_participants, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :discussion_entry_participants, :root_account_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class AddRootAccountIdToWebConferenceParticipants < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :web_conference_participants, :root_account_id, :accounts
|
||||
add_column_and_fk :web_conference_participants, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :web_conference_participants, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ class AddRootAccountIdToWebConferences < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column_and_fk :web_conferences, :root_account_id, :accounts
|
||||
add_column_and_fk :web_conferences, :root_account_id, :accounts, if_not_exists: true
|
||||
add_index :web_conferences, :root_account_id, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :web_conferences, :root_account_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
module MigrationHelpers::AddColumnAndFk
|
||||
def add_column_and_fk(table_name, column_name, foreign_table_name)
|
||||
def add_column_and_fk(table_name, column_name, foreign_table_name, if_not_exists: false)
|
||||
fk = connection.send(:foreign_key_name, table_name, :column => column_name)
|
||||
return if if_not_exists && connection.column_exists?(table_name, column_name)
|
||||
execute("ALTER TABLE #{connection.quote_table_name(table_name)} ADD COLUMN #{column_name} bigint CONSTRAINT #{fk} REFERENCES #{connection.quote_table_name(foreign_table_name)}(id)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue