diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /db/migrate | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'db/migrate')
82 files changed, 1594 insertions, 0 deletions
diff --git a/db/migrate/20200504191813_add_fingerprint_to_events.rb b/db/migrate/20200504191813_add_fingerprint_to_events.rb new file mode 100644 index 00000000000..1171d548f10 --- /dev/null +++ b/db/migrate/20200504191813_add_fingerprint_to_events.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class AddFingerprintToEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless column_exists?(:events, :fingerprint) + with_lock_retries { add_column :events, :fingerprint, :binary } + end + + unless check_constraint_exists?(:events, constraint_name) + add_check_constraint( + :events, + "octet_length(fingerprint) <= 128", + constraint_name, + validate: true + ) + end + end + + def down + remove_check_constraint(:events, constraint_name) + + if column_exists?(:events, :fingerprint) + with_lock_retries { remove_column :events, :fingerprint } + end + end + + def constraint_name + check_constraint_name(:events, :fingerprint, 'max_length') + end +end diff --git a/db/migrate/20200504200709_add_index_on_fingerprint_and_target_type_to_events.rb b/db/migrate/20200504200709_add_index_on_fingerprint_and_target_type_to_events.rb new file mode 100644 index 00000000000..9b06d593300 --- /dev/null +++ b/db/migrate/20200504200709_add_index_on_fingerprint_and_target_type_to_events.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIndexOnFingerprintAndTargetTypeToEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + KEYS = [:target_type, :target_id, :fingerprint] + + def up + add_concurrent_index :events, KEYS, using: :btree, unique: true + end + + def down + remove_concurrent_index :events, KEYS + end +end diff --git a/db/migrate/20200515152649_enable_btree_gist_extension.rb b/db/migrate/20200515152649_enable_btree_gist_extension.rb new file mode 100644 index 00000000000..686b685fb5d --- /dev/null +++ b/db/migrate/20200515152649_enable_btree_gist_extension.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class EnableBtreeGistExtension < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + execute 'CREATE EXTENSION IF NOT EXISTS btree_gist' + end + + def down + execute 'DROP EXTENSION IF EXISTS btree_gist' + end +end diff --git a/db/migrate/20200515153633_iteration_date_range_constraint.rb b/db/migrate/20200515153633_iteration_date_range_constraint.rb new file mode 100644 index 00000000000..ab197ff8ae7 --- /dev/null +++ b/db/migrate/20200515153633_iteration_date_range_constraint.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +class IterationDateRangeConstraint < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + execute <<~SQL + ALTER TABLE sprints + ADD CONSTRAINT iteration_start_and_due_daterange_project_id_constraint + EXCLUDE USING gist + ( project_id WITH =, + daterange(start_date, due_date, '[]') WITH && + ) + WHERE (project_id IS NOT NULL) + SQL + + execute <<~SQL + ALTER TABLE sprints + ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint + EXCLUDE USING gist + ( group_id WITH =, + daterange(start_date, due_date, '[]') WITH && + ) + WHERE (group_id IS NOT NULL) + SQL + end + + def down + execute <<~SQL + ALTER TABLE sprints + DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_project_id_constraint + SQL + + execute <<~SQL + ALTER TABLE sprints + DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint + SQL + end +end diff --git a/db/migrate/20200607223047_create_cluster_agents.rb b/db/migrate/20200607223047_create_cluster_agents.rb new file mode 100644 index 00000000000..50dd28562e4 --- /dev/null +++ b/db/migrate/20200607223047_create_cluster_agents.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class CreateClusterAgents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:cluster_agents) + with_lock_retries do + create_table :cluster_agents do |t| + t.timestamps_with_timezone null: false + t.belongs_to(:project, null: false, index: true, foreign_key: { on_delete: :cascade }) + t.text :name, null: false + + t.index [:project_id, :name], unique: true + end + end + end + + add_text_limit :cluster_agents, :name, 255 + end + + def down + with_lock_retries do + drop_table :cluster_agents + end + end +end diff --git a/db/migrate/20200607235435_create_cluster_agent_tokens.rb b/db/migrate/20200607235435_create_cluster_agent_tokens.rb new file mode 100644 index 00000000000..30c3ad30fa5 --- /dev/null +++ b/db/migrate/20200607235435_create_cluster_agent_tokens.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class CreateClusterAgentTokens < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:cluster_agent_tokens) + create_table :cluster_agent_tokens do |t| + t.timestamps_with_timezone null: false + t.belongs_to :agent, null: false, index: true, foreign_key: { to_table: :cluster_agents, on_delete: :cascade } + t.text :token_encrypted, null: false + + t.index :token_encrypted, unique: true + end + end + + add_text_limit :cluster_agent_tokens, :token_encrypted, 255 + end + + def down + drop_table :cluster_agent_tokens + end +end diff --git a/db/migrate/20200625193358_increase_size_on_instance_level_variable_values.rb b/db/migrate/20200625193358_increase_size_on_instance_level_variable_values.rb new file mode 100644 index 00000000000..ee665287a31 --- /dev/null +++ b/db/migrate/20200625193358_increase_size_on_instance_level_variable_values.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class IncreaseSizeOnInstanceLevelVariableValues < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + existing_constraint_name = text_limit_name(:ci_instance_variables, :encrypted_value) + new_constraint_name = check_constraint_name(:ci_instance_variables, :encrypted_value, :char_length_updated) + + add_text_limit(:ci_instance_variables, :encrypted_value, 13_579, constraint_name: new_constraint_name) + remove_check_constraint(:ci_instance_variables, existing_constraint_name) + end + + def down + # no-op + end +end diff --git a/db/migrate/20200701221303_change_default_value_of_ci_max_artifact_size_terraform_of_plan_limits_from_0_to_5.rb b/db/migrate/20200701221303_change_default_value_of_ci_max_artifact_size_terraform_of_plan_limits_from_0_to_5.rb new file mode 100644 index 00000000000..e295d2f601a --- /dev/null +++ b/db/migrate/20200701221303_change_default_value_of_ci_max_artifact_size_terraform_of_plan_limits_from_0_to_5.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class ChangeDefaultValueOfCiMaxArtifactSizeTerraformOfPlanLimitsFrom0To5 < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + change_column_default :plan_limits, :ci_max_artifact_size_terraform, 5 + execute('UPDATE plan_limits SET ci_max_artifact_size_terraform = 5 WHERE ci_max_artifact_size_terraform = 0') + end + end + + def down + with_lock_retries do + change_column_default :plan_limits, :ci_max_artifact_size_terraform, 0 + execute('UPDATE plan_limits SET ci_max_artifact_size_terraform = 0 WHERE ci_max_artifact_size_terraform = 5') + end + end +end diff --git a/db/migrate/20200703035021_add_notes_to_timelogs.rb b/db/migrate/20200703035021_add_notes_to_timelogs.rb new file mode 100644 index 00000000000..d711fd0400d --- /dev/null +++ b/db/migrate/20200703035021_add_notes_to_timelogs.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddNotesToTimelogs < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :timelogs, :note_id, :integer + end + add_concurrent_index :timelogs, :note_id + add_concurrent_foreign_key :timelogs, :notes, column: :note_id + end + + def down + remove_foreign_key_if_exists :timelogs, column: :note_id + remove_concurrent_index :timelogs, :note_id + with_lock_retries do + remove_column :timelogs, :note_id + end + end +end diff --git a/db/migrate/20200710152642_add_verification_state_to_terraform_states.rb b/db/migrate/20200710152642_add_verification_state_to_terraform_states.rb new file mode 100644 index 00000000000..71c14faab0c --- /dev/null +++ b/db/migrate/20200710152642_add_verification_state_to_terraform_states.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddVerificationStateToTerraformStates < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + change_table(:terraform_states) do |t| + t.column :verification_retry_at, :datetime_with_timezone + t.column :verified_at, :datetime_with_timezone + t.integer :verification_retry_count, limit: 2 + t.binary :verification_checksum, using: 'verification_checksum::bytea' + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20200710153009_add_verification_failure_limit_and_index_to_terraform_states + t.text :verification_failure + # rubocop:enable Migration/AddLimitToTextColumns + end + end +end diff --git a/db/migrate/20200710153009_add_verification_failure_limit_and_index_to_terraform_states.rb b/db/migrate/20200710153009_add_verification_failure_limit_and_index_to_terraform_states.rb new file mode 100644 index 00000000000..9d36a8faf4f --- /dev/null +++ b/db/migrate/20200710153009_add_verification_failure_limit_and_index_to_terraform_states.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddVerificationFailureLimitAndIndexToTerraformStates < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :terraform_states, :verification_failure, where: "(verification_failure IS NOT NULL)", name: "terraform_states_verification_failure_partial" + add_concurrent_index :terraform_states, :verification_checksum, where: "(verification_checksum IS NOT NULL)", name: "terraform_states_verification_checksum_partial" + add_text_limit :terraform_states, :verification_failure, 255 + end + + def down + remove_concurrent_index :terraform_states, :verification_failure + remove_concurrent_index :terraform_states, :verification_checksum + remove_text_limit :terraform_states, :verification_failure + end +end diff --git a/db/migrate/20200713141854_add_wiki_page_max_content_bytes_to_application_settings.rb b/db/migrate/20200713141854_add_wiki_page_max_content_bytes_to_application_settings.rb new file mode 100644 index 00000000000..c0763d9816c --- /dev/null +++ b/db/migrate/20200713141854_add_wiki_page_max_content_bytes_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddWikiPageMaxContentBytesToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :wiki_page_max_content_bytes, :bigint, default: 50.megabytes, null: false + end +end diff --git a/db/migrate/20200715124210_add_target_details_to_audit_event.rb b/db/migrate/20200715124210_add_target_details_to_audit_event.rb new file mode 100644 index 00000000000..65efe24a1e8 --- /dev/null +++ b/db/migrate/20200715124210_add_target_details_to_audit_event.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddTargetDetailsToAuditEvent < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + # rubocop:disable Migration/AddLimitToTextColumns + add_column(:audit_events, :target_details, :text) + # rubocop:enable Migration/AddLimitToTextColumns + end + end + + def down + with_lock_retries do + remove_column(:audit_events, :target_details) + end + end +end diff --git a/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb b/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb new file mode 100644 index 00000000000..6afa123c341 --- /dev/null +++ b/db/migrate/20200715135130_create_vulnerability_historical_statistics.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +class CreateVulnerabilityHistoricalStatistics < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + INDEX_NAME = 'index_vuln_historical_statistics_on_project_id_and_date' + + DOWNTIME = false + + def up + with_lock_retries do + create_table :vulnerability_historical_statistics do |t| + t.timestamps_with_timezone null: false + t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade } + t.integer :total, default: 0, null: false + t.integer :critical, default: 0, null: false + t.integer :high, default: 0, null: false + t.integer :medium, default: 0, null: false + t.integer :low, default: 0, null: false + t.integer :unknown, default: 0, null: false + t.integer :info, default: 0, null: false + t.date :date, null: false + t.integer :letter_grade, limit: 1, null: false + t.index [:project_id, :date], unique: true, name: INDEX_NAME + end + end + end + + def down + with_lock_retries do + drop_table :vulnerability_historical_statistics + end + end +end diff --git a/db/migrate/20200715171155_add_deployment_type_to_tracker.rb b/db/migrate/20200715171155_add_deployment_type_to_tracker.rb new file mode 100644 index 00000000000..649331ecb54 --- /dev/null +++ b/db/migrate/20200715171155_add_deployment_type_to_tracker.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDeploymentTypeToTracker < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :jira_tracker_data, :deployment_type, :smallint, default: 0, null: false + end +end diff --git a/db/migrate/20200716120000_partition_audit_events.rb b/db/migrate/20200716120000_partition_audit_events.rb new file mode 100644 index 00000000000..aef090339ea --- /dev/null +++ b/db/migrate/20200716120000_partition_audit_events.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class PartitionAuditEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + include Gitlab::Database::PartitioningMigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + partition_table_by_date :audit_events, :created_at + end + + def down + drop_partitioned_table_for :audit_events + end +end diff --git a/db/migrate/20200716145156_add_text_limit_to_audit_event_target_details.rb b/db/migrate/20200716145156_add_text_limit_to_audit_event_target_details.rb new file mode 100644 index 00000000000..43ee98b69e0 --- /dev/null +++ b/db/migrate/20200716145156_add_text_limit_to_audit_event_target_details.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddTextLimitToAuditEventTargetDetails < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_text_limit :audit_events, :target_details, 5_500 + end + + def down + remove_text_limit :audit_events, :target_details + end +end diff --git a/db/migrate/20200717080257_add_prevent_forking_to_namespace_settings.rb b/db/migrate/20200717080257_add_prevent_forking_to_namespace_settings.rb new file mode 100644 index 00000000000..b46daac6a98 --- /dev/null +++ b/db/migrate/20200717080257_add_prevent_forking_to_namespace_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddPreventForkingToNamespaceSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :namespace_settings, :prevent_forking_outside_group, :boolean, null: false, default: false + end +end diff --git a/db/migrate/20200717163656_add_moved_project_to_notification_settings.rb b/db/migrate/20200717163656_add_moved_project_to_notification_settings.rb new file mode 100644 index 00000000000..9c60a678c1f --- /dev/null +++ b/db/migrate/20200717163656_add_moved_project_to_notification_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddMovedProjectToNotificationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :notification_settings, :moved_project, :boolean, default: true, null: false + end +end diff --git a/db/migrate/20200718040100_add_index_on_merge_request_diffs_external_diff_store.rb b/db/migrate/20200718040100_add_index_on_merge_request_diffs_external_diff_store.rb new file mode 100644 index 00000000000..372a9df82a1 --- /dev/null +++ b/db/migrate/20200718040100_add_index_on_merge_request_diffs_external_diff_store.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexOnMergeRequestDiffsExternalDiffStore < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_request_diffs, :external_diff_store + end + + def down + remove_concurrent_index :merge_request_diffs, :external_diff_store + end +end diff --git a/db/migrate/20200718040200_add_index_on_terraform_states_file_store.rb b/db/migrate/20200718040200_add_index_on_terraform_states_file_store.rb new file mode 100644 index 00000000000..7dddcf1fcea --- /dev/null +++ b/db/migrate/20200718040200_add_index_on_terraform_states_file_store.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexOnTerraformStatesFileStore < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :terraform_states, :file_store + end + + def down + remove_concurrent_index :terraform_states, :file_store + end +end diff --git a/db/migrate/20200718040300_add_index_on_vulnerability_exports_file_store.rb b/db/migrate/20200718040300_add_index_on_vulnerability_exports_file_store.rb new file mode 100644 index 00000000000..c0d546ae112 --- /dev/null +++ b/db/migrate/20200718040300_add_index_on_vulnerability_exports_file_store.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexOnVulnerabilityExportsFileStore < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :vulnerability_exports, :file_store + end + + def down + remove_concurrent_index :vulnerability_exports, :file_store + end +end diff --git a/db/migrate/20200720053909_add_elasticsearch_indexed_file_size_limit_kb_to_application_settings.rb b/db/migrate/20200720053909_add_elasticsearch_indexed_file_size_limit_kb_to_application_settings.rb new file mode 100644 index 00000000000..bab5fe827d0 --- /dev/null +++ b/db/migrate/20200720053909_add_elasticsearch_indexed_file_size_limit_kb_to_application_settings.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddElasticsearchIndexedFileSizeLimitKbToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, + :elasticsearch_indexed_file_size_limit_kb, + :integer, + null: false, + default: 1024 # 1 MiB (units in KiB) + end +end diff --git a/db/migrate/20200720154007_create_vulnerabilities_export_verification_status.rb b/db/migrate/20200720154007_create_vulnerabilities_export_verification_status.rb new file mode 100644 index 00000000000..5cbb5fdd1e5 --- /dev/null +++ b/db/migrate/20200720154007_create_vulnerabilities_export_verification_status.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +class CreateVulnerabilitiesExportVerificationStatus < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:vulnerability_export_verification_status) + with_lock_retries do + create_table :vulnerability_export_verification_status, id: false do |t| + t.references :vulnerability_export, + primary_key: true, + null: false, + foreign_key: { on_delete: :cascade }, + index: + { name: 'index_vulnerability_export_verification_status_on_export_id' } + t.datetime_with_timezone :verification_retry_at + t.datetime_with_timezone :verified_at + t.integer :verification_retry_count, limit: 2 + t.binary :verification_checksum, using: 'verification_checksum::bytea' + t.text :verification_failure + + t.index :verification_failure, where: "(verification_failure IS NOT NULL)", name: "vulnerability_exports_verification_failure_partial" + t.index :verification_checksum, where: "(verification_checksum IS NOT NULL)", name: "vulnerability_exports_verification_checksum_partial" + end + end + end + + add_text_limit :vulnerability_export_verification_status, :verification_failure, 255 + end + + def down + return unless table_exists?(:vulnerability_export_verification_status) + + with_lock_retries do + drop_table :vulnerability_export_verification_status + end + end +end diff --git a/db/migrate/20200720154123_add_external_to_custom_emoji.rb b/db/migrate/20200720154123_add_external_to_custom_emoji.rb new file mode 100644 index 00000000000..2a97235eec4 --- /dev/null +++ b/db/migrate/20200720154123_add_external_to_custom_emoji.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddExternalToCustomEmoji < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :custom_emoji, :external, :boolean, default: true, null: false + end +end diff --git a/db/migrate/20200720191134_add_blocking_issues_count_to_issues.rb b/db/migrate/20200720191134_add_blocking_issues_count_to_issues.rb new file mode 100644 index 00000000000..dbb43541ad6 --- /dev/null +++ b/db/migrate/20200720191134_add_blocking_issues_count_to_issues.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class AddBlockingIssuesCountToIssues < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_issue_on_project_id_state_id_and_blocking_issues_count' + + disable_ddl_transaction! + + def up + unless column_exists?(:issues, :blocking_issues_count) + with_lock_retries do + add_column :issues, :blocking_issues_count, :integer, default: 0, null: false + end + end + + add_concurrent_index :issues, [:project_id, :state_id, :blocking_issues_count], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :issues, INDEX_NAME + + with_lock_retries do + remove_column :issues, :blocking_issues_count + end + end +end diff --git a/db/migrate/20200721034536_add_issue_type_to_issues.rb b/db/migrate/20200721034536_add_issue_type_to_issues.rb new file mode 100644 index 00000000000..96ae8c421da --- /dev/null +++ b/db/migrate/20200721034536_add_issue_type_to_issues.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddIssueTypeToIssues < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + # Set default to issue type + add_column :issues, :issue_type, :integer, limit: 2, default: 0, null: false + end + end + + def down + with_lock_retries do + remove_column :issues, :issue_type + end + end +end diff --git a/db/migrate/20200721043502_add_issue_type_index_to_issues.rb b/db/migrate/20200721043502_add_issue_type_index_to_issues.rb new file mode 100644 index 00000000000..2faad98d032 --- /dev/null +++ b/db/migrate/20200721043502_add_issue_type_index_to_issues.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIssueTypeIndexToIssues < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + disable_ddl_transaction! + + INCIDENT_TYPE = 1 + INDEX_NAME = 'index_issues_on_incident_issue_type' + + def up + add_concurrent_index :issues, + :issue_type, where: "issue_type = #{INCIDENT_TYPE}", + name: INDEX_NAME + end + + def down + remove_concurrent_index :issues, :issue_type + end +end diff --git a/db/migrate/20200721052853_create_dast_scanner_profile.rb b/db/migrate/20200721052853_create_dast_scanner_profile.rb new file mode 100644 index 00000000000..0dc0012d837 --- /dev/null +++ b/db/migrate/20200721052853_create_dast_scanner_profile.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class CreateDastScannerProfile < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:dast_scanner_profiles) + with_lock_retries do + create_table :dast_scanner_profiles do |t| + t.timestamps_with_timezone null: false + t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }, type: :integer + t.integer :spider_timeout, limit: 2 + t.integer :target_timeout, limit: 2 + t.text :name, null: false + t.index [:project_id, :name], unique: true + end + end + end + + add_text_limit(:dast_scanner_profiles, :name, 255) + end + + def down + with_lock_retries do + drop_table :dast_scanner_profiles + end + end +end diff --git a/db/migrate/20200721230558_add_index_to_projects_aimed_for_deletion.rb b/db/migrate/20200721230558_add_index_to_projects_aimed_for_deletion.rb new file mode 100644 index 00000000000..44dfe2ff3e1 --- /dev/null +++ b/db/migrate/20200721230558_add_index_to_projects_aimed_for_deletion.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AddIndexToProjectsAimedForDeletion < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + PROJECTS_AIMED_FOR_DELETION_INDEX_NAME = "index_projects_aimed_for_deletion" + MARKED_FOR_DELETION_PROJECTS_INDEX_NAME = "index_projects_on_marked_for_deletion_at" + + disable_ddl_transaction! + + def up + add_concurrent_index :projects, + :marked_for_deletion_at, + where: "marked_for_deletion_at IS NOT NULL AND pending_delete = false", + name: PROJECTS_AIMED_FOR_DELETION_INDEX_NAME + + remove_concurrent_index_by_name :projects, MARKED_FOR_DELETION_PROJECTS_INDEX_NAME + end + + def down + remove_concurrent_index_by_name :projects, PROJECTS_AIMED_FOR_DELETION_INDEX_NAME + + add_concurrent_index :projects, :marked_for_deletion_at, where: 'marked_for_deletion_at IS NOT NULL' + end +end diff --git a/db/migrate/20200722075411_add_ci_needs_size_limit_to_plan_limit.rb b/db/migrate/20200722075411_add_ci_needs_size_limit_to_plan_limit.rb new file mode 100644 index 00000000000..b615a09a61b --- /dev/null +++ b/db/migrate/20200722075411_add_ci_needs_size_limit_to_plan_limit.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddCiNeedsSizeLimitToPlanLimit < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :plan_limits, :ci_needs_size_limit, :integer, default: 50, null: false + end +end diff --git a/db/migrate/20200722084623_add_default_membership_role_to_saml_provider.rb b/db/migrate/20200722084623_add_default_membership_role_to_saml_provider.rb new file mode 100644 index 00000000000..bd82aab1aae --- /dev/null +++ b/db/migrate/20200722084623_add_default_membership_role_to_saml_provider.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddDefaultMembershipRoleToSamlProvider < ActiveRecord::Migration[6.0] + DOWNTIME = false + + GUEST_USER_ROLE = 10 + + def change + add_column :saml_providers, :default_membership_role, :smallint, default: GUEST_USER_ROLE, null: false + end +end diff --git a/db/migrate/20200722091435_add_relative_position_to_design_management_designs.rb b/db/migrate/20200722091435_add_relative_position_to_design_management_designs.rb new file mode 100644 index 00000000000..42b7a1d3898 --- /dev/null +++ b/db/migrate/20200722091435_add_relative_position_to_design_management_designs.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddRelativePositionToDesignManagementDesigns < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :design_management_designs, :relative_position, :integer + end +end diff --git a/db/migrate/20200722131241_create_resource_iteration_events_table.rb b/db/migrate/20200722131241_create_resource_iteration_events_table.rb new file mode 100644 index 00000000000..619faeaaadf --- /dev/null +++ b/db/migrate/20200722131241_create_resource_iteration_events_table.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateResourceIterationEventsTable < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + create_table :resource_iteration_events do |t| + t.bigint :user_id, null: false, index: { name: 'index_resource_iteration_events_on_user_id' } + t.bigint :issue_id, null: true, index: { name: 'index_resource_iteration_events_on_issue_id' } + t.bigint :merge_request_id, null: true, index: { name: 'index_resource_iteration_events_on_merge_request_id' } + t.bigint :iteration_id, index: { name: 'index_resource_iteration_events_on_iteration_id' } + t.datetime_with_timezone :created_at, null: false + t.integer :action, limit: 2, null: false + end + end +end diff --git a/db/migrate/20200722132040_add_users_fk_to_resource_iteration_events_table.rb b/db/migrate/20200722132040_add_users_fk_to_resource_iteration_events_table.rb new file mode 100644 index 00000000000..e28405be53d --- /dev/null +++ b/db/migrate/20200722132040_add_users_fk_to_resource_iteration_events_table.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddUsersFkToResourceIterationEventsTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :resource_iteration_events, :users, column: :user_id, on_delete: :nullify # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :resource_iteration_events, column: :user_id + end + end +end diff --git a/db/migrate/20200722132540_add_issues_fk_to_resource_iteration_events_table.rb b/db/migrate/20200722132540_add_issues_fk_to_resource_iteration_events_table.rb new file mode 100644 index 00000000000..adb10aaa707 --- /dev/null +++ b/db/migrate/20200722132540_add_issues_fk_to_resource_iteration_events_table.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIssuesFkToResourceIterationEventsTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :resource_iteration_events, :issues, column: :issue_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :resource_iteration_events, column: :issue_id + end + end +end diff --git a/db/migrate/20200722133040_add_merge_requests_fk_to_resource_iteration_events_table.rb b/db/migrate/20200722133040_add_merge_requests_fk_to_resource_iteration_events_table.rb new file mode 100644 index 00000000000..8b1859bb253 --- /dev/null +++ b/db/migrate/20200722133040_add_merge_requests_fk_to_resource_iteration_events_table.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddMergeRequestsFkToResourceIterationEventsTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :resource_iteration_events, :merge_requests, column: :merge_request_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :resource_iteration_events, column: :merge_request_id + end + end +end diff --git a/db/migrate/20200722133540_add_iterations_fk_to_resource_iteration_events_table.rb b/db/migrate/20200722133540_add_iterations_fk_to_resource_iteration_events_table.rb new file mode 100644 index 00000000000..b42c29a0634 --- /dev/null +++ b/db/migrate/20200722133540_add_iterations_fk_to_resource_iteration_events_table.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIterationsFkToResourceIterationEventsTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :resource_iteration_events, :sprints, column: :iteration_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :resource_iteration_events, column: :iteration_id + end + end +end diff --git a/db/migrate/20200723125205_add_target_project_id_to_mr_metrics.rb b/db/migrate/20200723125205_add_target_project_id_to_mr_metrics.rb new file mode 100644 index 00000000000..fb01b3fe046 --- /dev/null +++ b/db/migrate/20200723125205_add_target_project_id_to_mr_metrics.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddTargetProjectIdToMrMetrics < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_column :merge_request_metrics, :target_project_id, :integer + end + end + + def down + with_lock_retries do + remove_column :merge_request_metrics, :target_project_id, :integer + end + end +end diff --git a/db/migrate/20200723128332_add_fk_to_metrics_target_project_id.rb b/db/migrate/20200723128332_add_fk_to_metrics_target_project_id.rb new file mode 100644 index 00000000000..6536b20b9c1 --- /dev/null +++ b/db/migrate/20200723128332_add_fk_to_metrics_target_project_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddFkToMetricsTargetProjectId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(:merge_request_metrics, :target_project_id) + add_concurrent_foreign_key(:merge_request_metrics, :projects, column: :target_project_id, on_delete: :cascade) + end + + def down + remove_foreign_key(:merge_request_metrics, column: :target_project_id) + remove_concurrent_index(:merge_request_metrics, :target_project_id) + end +end diff --git a/db/migrate/20200724100123_add_index_on_vulnerability_historical_statistics_date.rb b/db/migrate/20200724100123_add_index_on_vulnerability_historical_statistics_date.rb new file mode 100644 index 00000000000..696f98b40f6 --- /dev/null +++ b/db/migrate/20200724100123_add_index_on_vulnerability_historical_statistics_date.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexOnVulnerabilityHistoricalStatisticsDate < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :vulnerability_historical_statistics, [:date, :id] + end + + def down + remove_concurrent_index :vulnerability_historical_statistics, [:date, :id] + end +end diff --git a/db/migrate/20200727082309_remove_index_chat_name_service_id.rb b/db/migrate/20200727082309_remove_index_chat_name_service_id.rb new file mode 100644 index 00000000000..49cda2dd41f --- /dev/null +++ b/db/migrate/20200727082309_remove_index_chat_name_service_id.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveIndexChatNameServiceId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index :chat_names, :service_id + end + + def down + add_concurrent_index :chat_names, :service_id + end +end diff --git a/db/migrate/20200727142337_update_defaults_for_sca_artifacts.rb b/db/migrate/20200727142337_update_defaults_for_sca_artifacts.rb new file mode 100644 index 00000000000..d745943a7d3 --- /dev/null +++ b/db/migrate/20200727142337_update_defaults_for_sca_artifacts.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class UpdateDefaultsForScaArtifacts < ActiveRecord::Migration[6.0] + DOWNTIME = false + + DEPENDENCY_SCANNING_LIMIT_MB = 350 + CONTAINER_SCANNING_LIMIT_MB = 150 + LICENSE_SCANNING_LIMIT_MB = 100 + + def up + change_column_default :plan_limits, :ci_max_artifact_size_dependency_scanning, DEPENDENCY_SCANNING_LIMIT_MB + change_column_default :plan_limits, :ci_max_artifact_size_container_scanning, CONTAINER_SCANNING_LIMIT_MB + change_column_default :plan_limits, :ci_max_artifact_size_license_scanning, LICENSE_SCANNING_LIMIT_MB + end + + def down + change_column_default :plan_limits, :ci_max_artifact_size_dependency_scanning, 0 + change_column_default :plan_limits, :ci_max_artifact_size_container_scanning, 0 + change_column_default :plan_limits, :ci_max_artifact_size_license_scanning, 0 + end +end diff --git a/db/migrate/20200728080250_replace_unique_index_on_cycle_analytics_stages.rb b/db/migrate/20200728080250_replace_unique_index_on_cycle_analytics_stages.rb new file mode 100644 index 00000000000..0e562ae27e2 --- /dev/null +++ b/db/migrate/20200728080250_replace_unique_index_on_cycle_analytics_stages.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class ReplaceUniqueIndexOnCycleAnalyticsStages < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + OLD_INDEX_NAME = 'index_analytics_ca_group_stages_on_group_id_and_name' + NEW_INDEX_NAME = 'index_group_stages_on_group_id_group_value_stream_id_and_name' + + disable_ddl_transaction! + + def up + add_concurrent_index(:analytics_cycle_analytics_group_stages, + [:group_id, :group_value_stream_id, :name], + unique: true, + name: NEW_INDEX_NAME) + + remove_concurrent_index_by_name :analytics_cycle_analytics_group_stages, OLD_INDEX_NAME + end + + def down + # Removing duplicated records (group_id, name) that would prevent re-creating the old index. + execute <<-SQL + DELETE FROM analytics_cycle_analytics_group_stages + USING ( + SELECT group_id, name, MIN(id) as min_id + FROM analytics_cycle_analytics_group_stages + GROUP BY group_id, name + HAVING COUNT(id) > 1 + ) as analytics_cycle_analytics_group_stages_name_duplicates + WHERE analytics_cycle_analytics_group_stages_name_duplicates.group_id = analytics_cycle_analytics_group_stages.group_id + AND analytics_cycle_analytics_group_stages_name_duplicates.name = analytics_cycle_analytics_group_stages.name + AND analytics_cycle_analytics_group_stages_name_duplicates.min_id <> analytics_cycle_analytics_group_stages.id + SQL + + add_concurrent_index(:analytics_cycle_analytics_group_stages, + [:group_id, :name], + unique: true, + name: OLD_INDEX_NAME) + + remove_concurrent_index_by_name :analytics_cycle_analytics_group_stages, NEW_INDEX_NAME + end +end diff --git a/db/migrate/20200728163009_add_deployment_events_to_web_hooks.rb b/db/migrate/20200728163009_add_deployment_events_to_web_hooks.rb new file mode 100644 index 00000000000..b1bf9560bcc --- /dev/null +++ b/db/migrate/20200728163009_add_deployment_events_to_web_hooks.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddDeploymentEventsToWebHooks < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :web_hooks, :deployment_events, :boolean, null: false, default: false + end +end diff --git a/db/migrate/20200728174137_add_index_on_design_management_designs_issue_id_and_relative_position_and_id.rb b/db/migrate/20200728174137_add_index_on_design_management_designs_issue_id_and_relative_position_and_id.rb new file mode 100644 index 00000000000..140c344e837 --- /dev/null +++ b/db/migrate/20200728174137_add_index_on_design_management_designs_issue_id_and_relative_position_and_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexOnDesignManagementDesignsIssueIdAndRelativePositionAndId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_design_management_designs_issue_id_relative_position_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :design_management_designs, [:issue_id, :relative_position, :id], name: INDEX_NAME + end + + def down + remove_concurrent_index :design_management_designs, [:issue_id, :relative_position, :id], name: INDEX_NAME + end +end diff --git a/db/migrate/20200728175710_add_enforce_namespace_storage_limit_to_application_settings.rb b/db/migrate/20200728175710_add_enforce_namespace_storage_limit_to_application_settings.rb new file mode 100644 index 00000000000..adbc86ec621 --- /dev/null +++ b/db/migrate/20200728175710_add_enforce_namespace_storage_limit_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddEnforceNamespaceStorageLimitToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :enforce_namespace_storage_limit, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20200729151021_add_after_expiry_notification_delivered_to_personal_access_tokens.rb b/db/migrate/20200729151021_add_after_expiry_notification_delivered_to_personal_access_tokens.rb new file mode 100644 index 00000000000..001436b7285 --- /dev/null +++ b/db/migrate/20200729151021_add_after_expiry_notification_delivered_to_personal_access_tokens.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddAfterExpiryNotificationDeliveredToPersonalAccessTokens < ActiveRecord::Migration[6.0] + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_column :personal_access_tokens, :after_expiry_notification_delivered, :boolean, null: false, default: false + end +end diff --git a/db/migrate/20200729175935_add_dashboard_path_to_prometheus_metrics.rb b/db/migrate/20200729175935_add_dashboard_path_to_prometheus_metrics.rb new file mode 100644 index 00000000000..0562e8d1c14 --- /dev/null +++ b/db/migrate/20200729175935_add_dashboard_path_to_prometheus_metrics.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class AddDashboardPathToPrometheusMetrics < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + # Text limit is added in 20200730210506_add_text_limit_to_dashboard_path + add_column :prometheus_metrics, :dashboard_path, :text # rubocop:disable Migration/AddLimitToTextColumns + end + + def down + remove_column :prometheus_metrics, :dashboard_path + end +end diff --git a/db/migrate/20200729180539_add_can_push_to_group_deploy_keys_groups.rb b/db/migrate/20200729180539_add_can_push_to_group_deploy_keys_groups.rb new file mode 100644 index 00000000000..3412790c20c --- /dev/null +++ b/db/migrate/20200729180539_add_can_push_to_group_deploy_keys_groups.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddCanPushToGroupDeployKeysGroups < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :group_deploy_keys_groups, :can_push, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20200729181641_add_index_to_resource_milestone_events_add_events.rb b/db/migrate/20200729181641_add_index_to_resource_milestone_events_add_events.rb new file mode 100644 index 00000000000..438f9c6bfa3 --- /dev/null +++ b/db/migrate/20200729181641_add_index_to_resource_milestone_events_add_events.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexToResourceMilestoneEventsAddEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + INDEX_NAME = 'index_resource_milestone_events_on_milestone_id_and_add_action' + ADD_ACTION = '1' + + def up + # Index add milestone events + add_concurrent_index :resource_milestone_events, :milestone_id, where: "action = #{ADD_ACTION}", name: INDEX_NAME + end + + def down + remove_concurrent_index :resource_milestone_events, :milestone_id, name: INDEX_NAME + end +end diff --git a/db/migrate/20200729191227_add_runbook_to_prometheus_alert.rb b/db/migrate/20200729191227_add_runbook_to_prometheus_alert.rb new file mode 100644 index 00000000000..a45b6eab1ee --- /dev/null +++ b/db/migrate/20200729191227_add_runbook_to_prometheus_alert.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class AddRunbookToPrometheusAlert < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + # limit is added in 20200501000002_add_text_limit_to_sprints_extended_title + add_column :prometheus_alerts, :runbook_url, :text # rubocop:disable Migration/AddLimitToTextColumns + end + + def down + remove_column :prometheus_alerts, :runbook_url + end +end diff --git a/db/migrate/20200729200808_add_text_limit_to_runbook_on_prometheus_alerts.rb b/db/migrate/20200729200808_add_text_limit_to_runbook_on_prometheus_alerts.rb new file mode 100644 index 00000000000..010b53ab35e --- /dev/null +++ b/db/migrate/20200729200808_add_text_limit_to_runbook_on_prometheus_alerts.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddTextLimitToRunbookOnPrometheusAlerts < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_text_limit :prometheus_alerts, :runbook_url, 255 + end + + def down + remove_text_limit :prometheus_alerts, :runbook_url + end +end diff --git a/db/migrate/20200729202222_add_index_to_ci_pipeline_project_id_created_at.rb b/db/migrate/20200729202222_add_index_to_ci_pipeline_project_id_created_at.rb new file mode 100644 index 00000000000..d1ee9c49d30 --- /dev/null +++ b/db/migrate/20200729202222_add_index_to_ci_pipeline_project_id_created_at.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexToCiPipelineProjectIdCreatedAt < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipelines, [:project_id, :created_at] + end + + def down + remove_concurrent_index :ci_pipelines, [:project_id, :created_at] + end +end diff --git a/db/migrate/20200730044810_add_indexes_to_resource_label_events_to_support_vsa.rb b/db/migrate/20200730044810_add_indexes_to_resource_label_events_to_support_vsa.rb new file mode 100644 index 00000000000..ba114e81618 --- /dev/null +++ b/db/migrate/20200730044810_add_indexes_to_resource_label_events_to_support_vsa.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class AddIndexesToResourceLabelEventsToSupportVsa < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + NEW_INDEX_NAME_ON_ISSUE_ID = 'index_resource_label_events_issue_id_label_id_action' + OLD_INDEX_NAME_ON_ISSUE_ID = 'index_resource_label_events_on_issue_id' + + NEW_INDEX_NAME_ON_MERGE_REQUEST_ID = 'index_resource_label_events_on_merge_request_id_label_id_action' + OLD_INDEX_NAME_ON_MERGE_REQUEST_ID = 'index_resource_label_events_on_merge_request_id' + + def up + add_concurrent_index :resource_label_events, [:issue_id, :label_id, :action], name: NEW_INDEX_NAME_ON_ISSUE_ID + remove_concurrent_index_by_name :resource_label_events, OLD_INDEX_NAME_ON_ISSUE_ID + + add_concurrent_index :resource_label_events, [:merge_request_id, :label_id, :action], name: NEW_INDEX_NAME_ON_MERGE_REQUEST_ID + remove_concurrent_index_by_name :resource_label_events, OLD_INDEX_NAME_ON_MERGE_REQUEST_ID + end + + def down + add_concurrent_index :resource_label_events, :issue_id, name: OLD_INDEX_NAME_ON_ISSUE_ID + remove_concurrent_index_by_name(:resource_label_events, NEW_INDEX_NAME_ON_ISSUE_ID) + + add_concurrent_index :resource_label_events, :merge_request_id, name: OLD_INDEX_NAME_ON_MERGE_REQUEST_ID + remove_concurrent_index_by_name(:resource_label_events, NEW_INDEX_NAME_ON_MERGE_REQUEST_ID) + end +end diff --git a/db/migrate/20200730083043_replace_index_for_service_usage_data.rb b/db/migrate/20200730083043_replace_index_for_service_usage_data.rb new file mode 100644 index 00000000000..0d3012c319d --- /dev/null +++ b/db/migrate/20200730083043_replace_index_for_service_usage_data.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class ReplaceIndexForServiceUsageData < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + OLD_INDEX_NAME = 'index_services_on_type_and_id_and_template_when_active' + NEW_INDEX_NAME = 'index_services_on_type_id_when_active_not_instance_not_template' + + disable_ddl_transaction! + + def up + add_concurrent_index :services, [:type, :id], where: 'active = TRUE AND instance = FALSE AND template = FALSE', name: NEW_INDEX_NAME + + remove_concurrent_index_by_name :services, OLD_INDEX_NAME + end + + def down + add_concurrent_index :services, [:type, :id, :template], where: 'active = TRUE', name: OLD_INDEX_NAME + + remove_concurrent_index :services, NEW_INDEX_NAME + end +end diff --git a/db/migrate/20200730131946_add_hide_lists_to_boards.rb b/db/migrate/20200730131946_add_hide_lists_to_boards.rb new file mode 100644 index 00000000000..e431ea852a7 --- /dev/null +++ b/db/migrate/20200730131946_add_hide_lists_to_boards.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddHideListsToBoards < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :boards, :hide_backlog_list, :boolean, default: false, null: false + add_column :boards, :hide_closed_list, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20200730210506_add_text_limit_to_dashboard_path.rb b/db/migrate/20200730210506_add_text_limit_to_dashboard_path.rb new file mode 100644 index 00000000000..a236cc68988 --- /dev/null +++ b/db/migrate/20200730210506_add_text_limit_to_dashboard_path.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddTextLimitToDashboardPath < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_text_limit(:prometheus_metrics, :dashboard_path, 2048) + end + + def down + remove_text_limit(:prometheus_metrics, :dashboard_path) + end +end diff --git a/db/migrate/20200731085019_create_experiment.rb b/db/migrate/20200731085019_create_experiment.rb new file mode 100644 index 00000000000..cd326e0958f --- /dev/null +++ b/db/migrate/20200731085019_create_experiment.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class CreateExperiment < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:experiments) + create_table :experiments do |t| + t.text :name, null: false + + t.index :name, unique: true + end + end + + add_text_limit :experiments, :name, 255 + end + + def down + drop_table :experiments + end +end diff --git a/db/migrate/20200731090553_create_experiment_user.rb b/db/migrate/20200731090553_create_experiment_user.rb new file mode 100644 index 00000000000..9080429dfd3 --- /dev/null +++ b/db/migrate/20200731090553_create_experiment_user.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class CreateExperimentUser < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + create_table :experiment_users do |t| + t.bigint :experiment_id, null: false + t.bigint :user_id, null: false + t.integer :group_type, limit: 2, null: false, default: 0 + t.timestamps_with_timezone null: false + end + + add_index :experiment_users, :experiment_id + add_index :experiment_users, :user_id + end + + def down + drop_table :experiment_users + end +end diff --git a/db/migrate/20200731201408_add_foreign_key_to_experiment_on_experiment_users.rb b/db/migrate/20200731201408_add_foreign_key_to_experiment_on_experiment_users.rb new file mode 100644 index 00000000000..3961803bf52 --- /dev/null +++ b/db/migrate/20200731201408_add_foreign_key_to_experiment_on_experiment_users.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddForeignKeyToExperimentOnExperimentUsers < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + # There is no need to use add_concurrent_foreign_key since it's an empty table + add_foreign_key :experiment_users, :experiments, column: :experiment_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :experiment_users, column: :experiment_id + end + end +end diff --git a/db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb b/db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb new file mode 100644 index 00000000000..42c337fecff --- /dev/null +++ b/db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddForeignKeyToUserOnExperimentUsers < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + # There is no need to use add_concurrent_foreign_key since it's an empty table + add_foreign_key :experiment_users, :users, column: :user_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :experiment_users, column: :user_id + end + end +end diff --git a/db/migrate/20200803111512_add_group_id_to_services.rb b/db/migrate/20200803111512_add_group_id_to_services.rb new file mode 100644 index 00000000000..7d4a0ef4dd5 --- /dev/null +++ b/db/migrate/20200803111512_add_group_id_to_services.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddGroupIdToServices < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :services, :group_id, :bigint + end +end diff --git a/db/migrate/20200803112806_add_index_group_id_to_services.rb b/db/migrate/20200803112806_add_index_group_id_to_services.rb new file mode 100644 index 00000000000..145009672ef --- /dev/null +++ b/db/migrate/20200803112806_add_index_group_id_to_services.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddIndexGroupIdToServices < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_services_on_unique_group_id_and_type' + + disable_ddl_transaction! + + def up + add_concurrent_index :services, [:group_id, :type], unique: true, name: INDEX_NAME + + add_concurrent_foreign_key :services, :namespaces, column: :group_id + end + + def down + remove_foreign_key_if_exists :services, column: :group_id + + remove_concurrent_index_by_name :services, INDEX_NAME + end +end diff --git a/db/migrate/20200803125340_create_raw_usage_data.rb b/db/migrate/20200803125340_create_raw_usage_data.rb new file mode 100644 index 00000000000..f1c23a7b0f5 --- /dev/null +++ b/db/migrate/20200803125340_create_raw_usage_data.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class CreateRawUsageData < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + unless table_exists?(:raw_usage_data) + create_table :raw_usage_data do |t| + t.timestamps_with_timezone + t.datetime_with_timezone :recorded_at, null: false + t.datetime_with_timezone :sent_at + t.jsonb :payload, null: false + + t.index [:recorded_at], unique: true + end + end + end + + def down + drop_table :raw_usage_data + end +end diff --git a/db/migrate/20200804041018_add_default_value_for_external_diff_store_to_merge_request_diffs.rb b/db/migrate/20200804041018_add_default_value_for_external_diff_store_to_merge_request_diffs.rb new file mode 100644 index 00000000000..1a565fef125 --- /dev/null +++ b/db/migrate/20200804041018_add_default_value_for_external_diff_store_to_merge_request_diffs.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddDefaultValueForExternalDiffStoreToMergeRequestDiffs < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + change_column_default :merge_request_diffs, :external_diff_store, 1 + end + end + + def down + with_lock_retries do + change_column_default :merge_request_diffs, :external_diff_store, nil + end + end +end diff --git a/db/migrate/20200804222543_add_resolved_on_default_branch_into_vulnerabilities_table.rb b/db/migrate/20200804222543_add_resolved_on_default_branch_into_vulnerabilities_table.rb new file mode 100644 index 00000000000..afb97871575 --- /dev/null +++ b/db/migrate/20200804222543_add_resolved_on_default_branch_into_vulnerabilities_table.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddResolvedOnDefaultBranchIntoVulnerabilitiesTable < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + change_table :vulnerabilities do |t| + t.boolean :resolved_on_default_branch, default: false, null: false + end + end +end diff --git a/db/migrate/20200805071842_add_index_on_end_date_and_namespace_id_to_gitlab_subscriptions.rb b/db/migrate/20200805071842_add_index_on_end_date_and_namespace_id_to_gitlab_subscriptions.rb new file mode 100644 index 00000000000..17b92b6b8a8 --- /dev/null +++ b/db/migrate/20200805071842_add_index_on_end_date_and_namespace_id_to_gitlab_subscriptions.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexOnEndDateAndNamespaceIdToGitlabSubscriptions < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :gitlab_subscriptions, [:end_date, :namespace_id] + end + + def down + remove_concurrent_index :gitlab_subscriptions, [:end_date, :namespace_id] + end +end diff --git a/db/migrate/20200805150316_create_ci_pipeline_artifact.rb b/db/migrate/20200805150316_create_ci_pipeline_artifact.rb new file mode 100644 index 00000000000..01995972011 --- /dev/null +++ b/db/migrate/20200805150316_create_ci_pipeline_artifact.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class CreateCiPipelineArtifact < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:ci_pipeline_artifacts) + create_table :ci_pipeline_artifacts do |t| + t.timestamps_with_timezone + t.bigint :pipeline_id, null: false, index: true + t.bigint :project_id, null: false, index: true + t.integer :size, null: false + t.integer :file_store, null: false, limit: 2 + t.integer :file_type, null: false, limit: 2 + t.integer :file_format, null: false, limit: 2 + t.text :file + + t.index [:pipeline_id, :file_type], unique: true + end + end + + add_text_limit :ci_pipeline_artifacts, :file, 255 + end + + def down + drop_table :ci_pipeline_artifacts + end +end diff --git a/db/migrate/20200805151001_add_foreign_key_to_pipeline_id_on_pipeline_artifact.rb b/db/migrate/20200805151001_add_foreign_key_to_pipeline_id_on_pipeline_artifact.rb new file mode 100644 index 00000000000..d6c3a4fe742 --- /dev/null +++ b/db/migrate/20200805151001_add_foreign_key_to_pipeline_id_on_pipeline_artifact.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddForeignKeyToPipelineIdOnPipelineArtifact < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :ci_pipeline_artifacts, :ci_pipelines, column: :pipeline_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :ci_pipeline_artifacts, column: :pipeline_id + end + end +end diff --git a/db/migrate/20200805151726_add_foreign_key_to_project_id_on_pipeline_artifact.rb b/db/migrate/20200805151726_add_foreign_key_to_project_id_on_pipeline_artifact.rb new file mode 100644 index 00000000000..367a2774d62 --- /dev/null +++ b/db/migrate/20200805151726_add_foreign_key_to_project_id_on_pipeline_artifact.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddForeignKeyToProjectIdOnPipelineArtifact < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_foreign_key :ci_pipeline_artifacts, :projects, column: :project_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :ci_pipeline_artifacts, column: :project_id + end + end +end diff --git a/db/migrate/20200806004232_add_default_value_for_file_store_to_package_files.rb b/db/migrate/20200806004232_add_default_value_for_file_store_to_package_files.rb new file mode 100644 index 00000000000..06f033891fc --- /dev/null +++ b/db/migrate/20200806004232_add_default_value_for_file_store_to_package_files.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddDefaultValueForFileStoreToPackageFiles < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + change_column_default :packages_package_files, :file_store, 1 + end + end + + def down + with_lock_retries do + change_column_default :packages_package_files, :file_store, nil + end + end +end diff --git a/db/migrate/20200807070820_add_index_for_compliance_merged_merge_request_to_events.rb b/db/migrate/20200807070820_add_index_for_compliance_merged_merge_request_to_events.rb new file mode 100644 index 00000000000..4650437056e --- /dev/null +++ b/db/migrate/20200807070820_add_index_for_compliance_merged_merge_request_to_events.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddIndexForComplianceMergedMergeRequestToEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_events_on_project_id_and_id_desc_on_merged_action' + + disable_ddl_transaction! + + def up + add_concurrent_index :events, [:project_id, :id], + order: { id: :desc }, + where: "action = 7", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :events, INDEX_NAME + end +end diff --git a/db/migrate/20200807132726_add_delete_original_index_at_to_reindexing_tasks.rb b/db/migrate/20200807132726_add_delete_original_index_at_to_reindexing_tasks.rb new file mode 100644 index 00000000000..435b2a45e85 --- /dev/null +++ b/db/migrate/20200807132726_add_delete_original_index_at_to_reindexing_tasks.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddDeleteOriginalIndexAtToReindexingTasks < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_column :elastic_reindexing_tasks, :delete_original_index_at, :datetime_with_timezone + end + end + + def down + with_lock_retries do + remove_column :elastic_reindexing_tasks, :delete_original_index_at + end + end +end diff --git a/db/migrate/20200807150937_add_file_count_to_merge_request_diffs.rb b/db/migrate/20200807150937_add_file_count_to_merge_request_diffs.rb new file mode 100644 index 00000000000..3afc246d698 --- /dev/null +++ b/db/migrate/20200807150937_add_file_count_to_merge_request_diffs.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddFileCountToMergeRequestDiffs < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :merge_request_diffs, :files_count, :smallint + end + end + + def down + with_lock_retries do + remove_column :merge_request_diffs, :files_count, :smallint + end + end +end diff --git a/db/migrate/20200810152043_add_expire_at_to_ci_pipeline_artifact.rb b/db/migrate/20200810152043_add_expire_at_to_ci_pipeline_artifact.rb new file mode 100644 index 00000000000..1aaa0f36f16 --- /dev/null +++ b/db/migrate/20200810152043_add_expire_at_to_ci_pipeline_artifact.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddExpireAtToCiPipelineArtifact < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :ci_pipeline_artifacts, :expire_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20200811055018_remove_not_null_constraint_on_type_from_audit_events.rb b/db/migrate/20200811055018_remove_not_null_constraint_on_type_from_audit_events.rb new file mode 100644 index 00000000000..25c3ef71655 --- /dev/null +++ b/db/migrate/20200811055018_remove_not_null_constraint_on_type_from_audit_events.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class RemoveNotNullConstraintOnTypeFromAuditEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + # To avoid deadlock on audit_event and audit_event_part... since there is a trigger to insert record from audit_events + # to audit_events_part..., we need to ensure each ALTER TABLE command run in its own transaction. + def up + with_lock_retries do + change_column_null :audit_events_part_5fc467ac26, :type, true + end + + with_lock_retries do + change_column_null :audit_events, :type, true + end + end + + def down + # no-op -- null values might be added after this constraint is removed. + end +end diff --git a/db/migrate/20200811194848_add_default_value_for_file_store_to_pipeline_artifact.rb b/db/migrate/20200811194848_add_default_value_for_file_store_to_pipeline_artifact.rb new file mode 100644 index 00000000000..f689a505809 --- /dev/null +++ b/db/migrate/20200811194848_add_default_value_for_file_store_to_pipeline_artifact.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddDefaultValueForFileStoreToPipelineArtifact < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + PIPELINE_ARTIFACT_LOCAL_FILE_STORE = 1 + + def up + with_lock_retries do + change_column_default :ci_pipeline_artifacts, :file_store, PIPELINE_ARTIFACT_LOCAL_FILE_STORE + end + end + + def down + with_lock_retries do + change_column_default :ci_pipeline_artifacts, :file_store, nil + end + end +end diff --git a/db/migrate/20200812112204_add_index_to_mr_metrics_target_project_id.rb b/db/migrate/20200812112204_add_index_to_mr_metrics_target_project_id.rb new file mode 100644 index 00000000000..da483e7222c --- /dev/null +++ b/db/migrate/20200812112204_add_index_to_mr_metrics_target_project_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToMrMetricsTargetProjectId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_merge_request_metrics_on_target_project_id_merged_at' + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_request_metrics, [:target_project_id, :merged_at], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name(:merge_request_metrics, INDEX_NAME) + end +end diff --git a/db/migrate/20200813143304_add_new_external_diff_migration_index.rb b/db/migrate/20200813143304_add_new_external_diff_migration_index.rb new file mode 100644 index 00000000000..64611e4f50a --- /dev/null +++ b/db/migrate/20200813143304_add_new_external_diff_migration_index.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class AddNewExternalDiffMigrationIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_merge_request_diffs_by_id_partial' + + disable_ddl_transaction! + + def up + add_concurrent_index( + :merge_request_diffs, + :id, + name: INDEX_NAME, + where: 'files_count > 0 AND ((NOT stored_externally) OR (stored_externally IS NULL))' + ) + end + + def down + remove_concurrent_index_by_name(:merge_request_diffs, INDEX_NAME) + end +end diff --git a/db/migrate/20200813143356_remove_old_external_diff_migration_index.rb b/db/migrate/20200813143356_remove_old_external_diff_migration_index.rb new file mode 100644 index 00000000000..9b466f8734f --- /dev/null +++ b/db/migrate/20200813143356_remove_old_external_diff_migration_index.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class RemoveOldExternalDiffMigrationIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name( + :merge_request_diffs, + 'index_merge_request_diffs_on_merge_request_id_and_id_partial' + ) + end + + def down + add_concurrent_index( + :merge_request_diffs, + [:merge_request_id, :id], + where: { stored_externally: [nil, false] } + ) + end +end diff --git a/db/migrate/20200817142800_add_pipeline_artifacts_size_to_project_statistics.rb b/db/migrate/20200817142800_add_pipeline_artifacts_size_to_project_statistics.rb new file mode 100644 index 00000000000..a15d94a41b7 --- /dev/null +++ b/db/migrate/20200817142800_add_pipeline_artifacts_size_to_project_statistics.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddPipelineArtifactsSizeToProjectStatistics < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_column :project_statistics, :pipeline_artifacts_size, :bigint, default: 0, null: false + end + end + + def down + with_lock_retries do + remove_column :project_statistics, :pipeline_artifacts_size, :bigint, default: 0, null: false + end + end +end |