diff options
Diffstat (limited to 'db')
9 files changed, 48 insertions, 2 deletions
diff --git a/db/migrate/20181016141739_add_status_to_deployments.rb b/db/migrate/20181016141739_add_status_to_deployments.rb index 7aaf029b69c..103bd9cc56d 100644 --- a/db/migrate/20181016141739_add_status_to_deployments.rb +++ b/db/migrate/20181016141739_add_status_to_deployments.rb @@ -14,14 +14,18 @@ class AddStatusToDeployments < ActiveRecord::Migration[4.2] # Ideally, `status` column should not have default value because it should be leveraged by state machine (i.e. application level). # However, we have to use the default value for avoiding `NOT NULL` violation during the transition period. # The default value should be removed in the future release. + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up - add_column_with_default(:deployments, # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(:deployments, :status, :integer, limit: 2, default: DEPLOYMENT_STATUS_SUCCESS, allow_null: false) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:deployments, :status) diff --git a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb index 60d4c2554f7..2488cff38af 100644 --- a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb +++ b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb @@ -7,10 +7,12 @@ class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false end + # rubocop:enable Migration/AddColumnWithDefault # rubocop:enable Migration/UpdateLargeTable def down diff --git a/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb b/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb index aa3002a3dcd..1a4439da5bf 100644 --- a/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb +++ b/db/migrate/20190416213615_add_variable_type_to_ci_pipeline_variables.rb @@ -7,9 +7,13 @@ class AddVariableTypeToCiPipelineVariables < ActiveRecord::Migration[5.0] DOWNTIME = false ENV_VAR_VARIABLE_TYPE = 1 + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up - add_column_with_default(:ci_pipeline_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(:ci_pipeline_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:ci_pipeline_variables, :variable_type) diff --git a/db/migrate/20190426180107_add_deployment_events_to_services.rb b/db/migrate/20190426180107_add_deployment_events_to_services.rb index 1fb137fb5f9..61339ea7506 100644 --- a/db/migrate/20190426180107_add_deployment_events_to_services.rb +++ b/db/migrate/20190426180107_add_deployment_events_to_services.rb @@ -7,9 +7,13 @@ class AddDeploymentEventsToServices < ActiveRecord::Migration[5.0] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default(:services, :deployment_events, :boolean, default: false, allow_null: false) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:services, :deployment_events) diff --git a/db/migrate/20191023093207_add_comment_actions_to_services.rb b/db/migrate/20191023093207_add_comment_actions_to_services.rb index f3fc12ac7c7..46d4bdf9500 100644 --- a/db/migrate/20191023093207_add_comment_actions_to_services.rb +++ b/db/migrate/20191023093207_add_comment_actions_to_services.rb @@ -7,9 +7,13 @@ class AddCommentActionsToServices < ActiveRecord::Migration[5.2] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default(:services, :comment_on_event_enabled, :boolean, default: true) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:services, :comment_on_event_enabled) diff --git a/db/migrate/20200310132654_add_instance_to_services.rb b/db/migrate/20200310132654_add_instance_to_services.rb index 85b16a4094c..5f3c3e8616b 100644 --- a/db/migrate/20200310132654_add_instance_to_services.rb +++ b/db/migrate/20200310132654_add_instance_to_services.rb @@ -7,9 +7,13 @@ class AddInstanceToServices < ActiveRecord::Migration[6.0] disable_ddl_transaction! + # rubocop:disable Migration/AddColumnWithDefault + # rubocop:disable Migration/UpdateLargeTable def up add_column_with_default(:services, :instance, :boolean, default: false) end + # rubocop:enable Migration/AddColumnWithDefault + # rubocop:enable Migration/UpdateLargeTable def down remove_column(:services, :instance) diff --git a/db/post_migrate/20200212052620_readd_template_column_to_services.rb b/db/post_migrate/20200212052620_readd_template_column_to_services.rb index e54b9e39277..2b0d26b2ad4 100644 --- a/db/post_migrate/20200212052620_readd_template_column_to_services.rb +++ b/db/post_migrate/20200212052620_readd_template_column_to_services.rb @@ -7,6 +7,7 @@ class ReaddTemplateColumnToServices < ActiveRecord::Migration[6.0] disable_ddl_transaction! + # rubocop:disable Migration/UpdateLargeTable def up return if column_exists? :services, :template @@ -16,6 +17,7 @@ class ReaddTemplateColumnToServices < ActiveRecord::Migration[6.0] # of `template`, we would look for entries with `project_id IS NULL`. add_column_with_default :services, :template, :boolean, default: false, allow_null: true end + # rubocop:enable Migration/UpdateLargeTable def down # NOP since the column is expected to exist diff --git a/db/post_migrate/20200311192351_add_index_on_noteable_type_and_noteable_id_to_sent_notifications.rb b/db/post_migrate/20200311192351_add_index_on_noteable_type_and_noteable_id_to_sent_notifications.rb new file mode 100644 index 00000000000..fa0246218c3 --- /dev/null +++ b/db/post_migrate/20200311192351_add_index_on_noteable_type_and_noteable_id_to_sent_notifications.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexOnNoteableTypeAndNoteableIdToSentNotifications < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_sent_notifications_on_noteable_type_noteable_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :sent_notifications, + [:noteable_id], + name: INDEX_NAME, + where: "noteable_type = 'Issue'" + end + + def down + remove_concurrent_index_by_name :sent_notifications, INDEX_NAME + end +end diff --git a/db/schema.rb b/db/schema.rb index db9ba2ce8f5..f3a475bbfe9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -3919,6 +3919,7 @@ ActiveRecord::Schema.define(version: 2020_03_13_123934) do t.string "note_type" t.text "position" t.string "in_reply_to_discussion_id" + t.index ["noteable_id"], name: "index_sent_notifications_on_noteable_type_noteable_id", where: "((noteable_type)::text = 'Issue'::text)" t.index ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true end |