summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
commit905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch)
tree756d138db422392c00471ab06acdff92c5a9b69c /db/migrate
parent50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff)
downloadgitlab-ce-905c1110b08f93a19661cf42a276c7ea90d0a0ff.tar.gz
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20180113220114_rework_redirect_routes_indexes.rb4
-rw-r--r--db/migrate/20190801142441_add_throttle_protected_path_columns.rb25
-rw-r--r--db/migrate/20190807023052_design_issue_id_nullable.rb11
-rw-r--r--db/migrate/20190821040941_create_cluster_providers_aws.rb33
-rw-r--r--db/migrate/20190901174200_add_max_issue_count_to_list.rb16
-rw-r--r--db/migrate/20190903150358_create_analytics_repository_files_table.rb21
-rw-r--r--db/migrate/20190903150435_create_analytics_repository_file_edits_table.rb29
-rw-r--r--db/migrate/20190905022045_add_issues_prometheus_alert_event_join_table.rb22
-rw-r--r--db/migrate/20190905074652_index_timestamp_columns_for_issue_metrics.rb29
-rw-r--r--db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb17
-rw-r--r--db/migrate/20190909045845_create_project_pages_metadata.rb14
-rw-r--r--db/migrate/20190911115056_add_projects_max_pages_size.rb9
-rw-r--r--db/migrate/20190911115109_add_namespaces_max_pages_size.rb9
-rw-r--r--db/migrate/20190911115207_add_projects_max_artifacts_size.rb9
-rw-r--r--db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb9
-rw-r--r--db/migrate/20190912223232_add_role_to_users.rb12
-rw-r--r--db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb13
-rw-r--r--db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb17
-rw-r--r--db/migrate/20190918025618_add_user_and_timestamps_to_design_management_versions.rb16
-rw-r--r--db/migrate/20190918102042_create_grafana_integrations.rb15
-rw-r--r--db/migrate/20190919040324_add_successfull_pages_deploy_partial_index_on_ci_builds.rb23
-rw-r--r--db/migrate/20190919091300_create_evidences.rb14
-rw-r--r--db/migrate/20190919104119_index_timestamp_columns_for_merge_requests_creation_date.rb29
-rw-r--r--db/migrate/20190919162036_add_index_to_clusters_providers_gcp_on_cloud_run.rb17
-rw-r--r--db/migrate/20190919183411_add_index_packages_on_name_trigram_to_packages_packages.rb18
-rw-r--r--db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb24
-rw-r--r--db/migrate/20190924124627_add_pull_mirror_branch_prefix_to_projects.rb9
-rw-r--r--db/migrate/20190925055714_default_request_access_groups.rb15
-rw-r--r--db/migrate/20190925055902_default_request_access_projects.rb15
-rw-r--r--db/migrate/20190926041216_add_user_indexes_to_design_management_versions.rb19
-rw-r--r--db/migrate/20190927055500_create_description_versions.rb29
-rw-r--r--db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb19
-rw-r--r--db/migrate/20190927074328_add_index_on_snippet_content.rb18
-rw-r--r--db/migrate/20190929180751_create_vulnerabilities.rb39
-rw-r--r--db/migrate/20190929180813_add_reference_from_vulnerability_occurrences_to_occurrences.rb14
-rw-r--r--db/migrate/20190929180827_add_foreign_keys_and_indexes_to_vulnerabilities.rb76
-rw-r--r--db/migrate/20190930025655_add_incident_management_throttle_columns_to_application_setting.rb30
-rw-r--r--db/migrate/20190930063627_add_management_project_id_to_clusters.rb9
-rw-r--r--db/migrate/20190930082942_add_new_release_to_notification_settings.rb9
-rw-r--r--db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb19
-rw-r--r--db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb21
-rw-r--r--db/migrate/20191003060227_add_push_event_hooks_limit_to_application_settings.rb17
-rw-r--r--db/migrate/20191003064615_create_aws_roles.rb21
-rw-r--r--db/migrate/20191004133612_create_analytics_repository_file_commits.rb19
-rw-r--r--db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb17
-rw-r--r--db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb11
-rw-r--r--db/migrate/20191008180203_add_issuable_state_id_indexes.rb75
-rw-r--r--db/migrate/20191008200204_add_state_id_default_value.rb24
-rw-r--r--db/migrate/20191009222222_add_custom_http_clone_url_root_to_application_settings.rb13
-rw-r--r--db/migrate/20191014084150_add_index_on_snippets_project_id_and_visibility_level.rb17
-rw-r--r--db/migrate/20191014132931_remove_index_on_snippets_project_id.rb17
-rw-r--r--db/migrate/20191016072826_replace_ci_trigger_requests_index.rb21
-rw-r--r--db/migrate/20191016220135_add_join_table_for_self_managed_prometheus_alert_issues.rb22
53 files changed, 1067 insertions, 3 deletions
diff --git a/db/migrate/20180113220114_rework_redirect_routes_indexes.rb b/db/migrate/20180113220114_rework_redirect_routes_indexes.rb
index 4c3bb0a26ce..2b9365ce827 100644
--- a/db/migrate/20180113220114_rework_redirect_routes_indexes.rb
+++ b/db/migrate/20180113220114_rework_redirect_routes_indexes.rb
@@ -20,9 +20,7 @@ class ReworkRedirectRoutesIndexes < ActiveRecord::Migration[4.2]
def up
disable_statement_timeout do
# this is a plain btree on a single boolean column. It'll never be
- # selective enough to be valuable. This class is called by
- # setup_postgresql.rake so it needs to be able to handle this
- # index not existing.
+ # selective enough to be valuable.
if index_exists?(:redirect_routes, :permanent)
remove_concurrent_index(:redirect_routes, :permanent)
end
diff --git a/db/migrate/20190801142441_add_throttle_protected_path_columns.rb b/db/migrate/20190801142441_add_throttle_protected_path_columns.rb
new file mode 100644
index 00000000000..bb6d54f3b7b
--- /dev/null
+++ b/db/migrate/20190801142441_add_throttle_protected_path_columns.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddThrottleProtectedPathColumns < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ DEFAULT_PROTECTED_PATHS = [
+ '/users/password',
+ '/users/sign_in',
+ '/api/v3/session.json',
+ '/api/v3/session',
+ '/api/v4/session.json',
+ '/api/v4/session',
+ '/users',
+ '/users/confirmation',
+ '/unsubscribes/',
+ '/import/github/personal_access_token'
+ ]
+
+ def change
+ add_column :application_settings, :throttle_protected_paths_enabled, :boolean, default: true, null: false
+ add_column :application_settings, :throttle_protected_paths_requests_per_period, :integer, default: 10, null: false
+ add_column :application_settings, :throttle_protected_paths_period_in_seconds, :integer, default: 60, null: false
+ add_column :application_settings, :protected_paths, :string, array: true, limit: 255, default: DEFAULT_PROTECTED_PATHS
+ end
+end
diff --git a/db/migrate/20190807023052_design_issue_id_nullable.rb b/db/migrate/20190807023052_design_issue_id_nullable.rb
new file mode 100644
index 00000000000..4429e23d520
--- /dev/null
+++ b/db/migrate/20190807023052_design_issue_id_nullable.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class DesignIssueIdNullable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_column_null :design_management_designs, :issue_id, true
+ end
+end
diff --git a/db/migrate/20190821040941_create_cluster_providers_aws.rb b/db/migrate/20190821040941_create_cluster_providers_aws.rb
new file mode 100644
index 00000000000..f80559861c4
--- /dev/null
+++ b/db/migrate/20190821040941_create_cluster_providers_aws.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class CreateClusterProvidersAws < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :cluster_providers_aws do |t|
+ t.references :cluster, null: false, type: :bigint, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :created_by_user, type: :integer, foreign_key: { on_delete: :nullify, to_table: :users }
+
+ t.integer :num_nodes, null: false
+ t.integer :status, null: false
+
+ t.timestamps_with_timezone null: false
+
+ t.string :key_name, null: false, limit: 255
+ t.string :role_arn, null: false, limit: 2048
+ t.string :region, null: false, limit: 255
+ t.string :vpc_id, null: false, limit: 255
+ t.string :subnet_ids, null: false, array: true, default: [], limit: 255
+ t.string :security_group_id, null: false, limit: 255
+ t.string :instance_type, null: false, limit: 255
+
+ t.string :access_key_id, limit: 255
+ t.string :encrypted_secret_access_key_iv, limit: 255
+ t.text :encrypted_secret_access_key
+ t.text :session_token
+ t.text :status_reason
+
+ t.index [:cluster_id, :status]
+ end
+ end
+end
diff --git a/db/migrate/20190901174200_add_max_issue_count_to_list.rb b/db/migrate/20190901174200_add_max_issue_count_to_list.rb
new file mode 100644
index 00000000000..59359f28d6a
--- /dev/null
+++ b/db/migrate/20190901174200_add_max_issue_count_to_list.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddMaxIssueCountToList < ActiveRecord::Migration[4.2]
+ include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ add_column_with_default :lists, :max_issue_count, :integer, default: 0
+ end
+
+ def down
+ remove_column :lists, :max_issue_count
+ end
+end
diff --git a/db/migrate/20190903150358_create_analytics_repository_files_table.rb b/db/migrate/20190903150358_create_analytics_repository_files_table.rb
new file mode 100644
index 00000000000..e7c30a149f9
--- /dev/null
+++ b/db/migrate/20190903150358_create_analytics_repository_files_table.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreateAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :analytics_repository_files do |t|
+ t.references :project,
+ index: false,
+ foreign_key: { on_delete: :cascade },
+ null: false
+ t.string :file_path,
+ limit: 4096,
+ null: false
+ end
+
+ add_index :analytics_repository_files, [:project_id, :file_path], unique: true
+ end
+end
diff --git a/db/migrate/20190903150435_create_analytics_repository_file_edits_table.rb b/db/migrate/20190903150435_create_analytics_repository_file_edits_table.rb
new file mode 100644
index 00000000000..dca3fa1b37d
--- /dev/null
+++ b/db/migrate/20190903150435_create_analytics_repository_file_edits_table.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateAnalyticsRepositoryFileEditsTable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :analytics_repository_file_edits do |t|
+ t.references :project,
+ index: true,
+ foreign_key: { on_delete: :cascade }, null: false
+ t.references :analytics_repository_file,
+ index: false,
+ foreign_key: { on_delete: :cascade },
+ null: false
+ t.date :committed_date,
+ null: false
+ t.integer :num_edits,
+ null: false,
+ default: 0
+ end
+
+ add_index :analytics_repository_file_edits,
+ [:analytics_repository_file_id, :committed_date, :project_id],
+ name: 'index_file_edits_on_committed_date_file_id_and_project_id',
+ unique: true
+ end
+end
diff --git a/db/migrate/20190905022045_add_issues_prometheus_alert_event_join_table.rb b/db/migrate/20190905022045_add_issues_prometheus_alert_event_join_table.rb
new file mode 100644
index 00000000000..861b97f0a09
--- /dev/null
+++ b/db/migrate/20190905022045_add_issues_prometheus_alert_event_join_table.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddIssuesPrometheusAlertEventJoinTable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :issues_prometheus_alert_events, id: false do |t|
+ t.references :issue, null: false,
+ index: false, # Uses the index below
+ foreign_key: { on_delete: :cascade }
+ t.references :prometheus_alert_event, null: false,
+ index: { name: 'issue_id_issues_prometheus_alert_events_index' },
+ foreign_key: { on_delete: :cascade }
+
+ t.timestamps_with_timezone
+ t.index [:issue_id, :prometheus_alert_event_id],
+ unique: true, name: 'issue_id_prometheus_alert_event_id_index'
+ end
+ end
+end
diff --git a/db/migrate/20190905074652_index_timestamp_columns_for_issue_metrics.rb b/db/migrate/20190905074652_index_timestamp_columns_for_issue_metrics.rb
new file mode 100644
index 00000000000..e468b2decd9
--- /dev/null
+++ b/db/migrate/20190905074652_index_timestamp_columns_for_issue_metrics.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class IndexTimestampColumnsForIssueMetrics < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(*index_arguments)
+ end
+
+ def down
+ remove_concurrent_index(*index_arguments)
+ end
+
+ private
+
+ def index_arguments
+ [
+ :issue_metrics,
+ [:issue_id, :first_mentioned_in_commit_at, :first_associated_with_milestone_at, :first_added_to_board_at],
+ {
+ name: 'index_issue_metrics_on_issue_id_and_timestamps'
+ }
+ ]
+ end
+end
diff --git a/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb b/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb
new file mode 100644
index 00000000000..e7ffd7cd4d3
--- /dev/null
+++ b/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddCloudRunToClustersProvidersGcp < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:cluster_providers_gcp, :cloud_run, :boolean, default: false)
+ end
+
+ def down
+ remove_column(:cluster_providers_gcp, :cloud_run)
+ end
+end
diff --git a/db/migrate/20190909045845_create_project_pages_metadata.rb b/db/migrate/20190909045845_create_project_pages_metadata.rb
new file mode 100644
index 00000000000..5fc8fc6e6c1
--- /dev/null
+++ b/db/migrate/20190909045845_create_project_pages_metadata.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateProjectPagesMetadata < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :project_pages_metadata, id: false do |t|
+ t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.boolean :deployed, null: false, default: false
+
+ t.index :project_id, name: 'index_project_pages_metadata_on_project_id_and_deployed_is_true', where: "deployed = TRUE"
+ end
+ end
+end
diff --git a/db/migrate/20190911115056_add_projects_max_pages_size.rb b/db/migrate/20190911115056_add_projects_max_pages_size.rb
new file mode 100644
index 00000000000..175c66953ed
--- /dev/null
+++ b/db/migrate/20190911115056_add_projects_max_pages_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectsMaxPagesSize < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :projects, :max_pages_size, :integer
+ end
+end
diff --git a/db/migrate/20190911115109_add_namespaces_max_pages_size.rb b/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
new file mode 100644
index 00000000000..c14dfa74a5a
--- /dev/null
+++ b/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNamespacesMaxPagesSize < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :namespaces, :max_pages_size, :integer
+ end
+end
diff --git a/db/migrate/20190911115207_add_projects_max_artifacts_size.rb b/db/migrate/20190911115207_add_projects_max_artifacts_size.rb
new file mode 100644
index 00000000000..41cab7e5282
--- /dev/null
+++ b/db/migrate/20190911115207_add_projects_max_artifacts_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectsMaxArtifactsSize < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :projects, :max_artifacts_size, :integer
+ end
+end
diff --git a/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb b/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
new file mode 100644
index 00000000000..60c594c47a6
--- /dev/null
+++ b/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNamespacesMaxArtifactsSize < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :namespaces, :max_artifacts_size, :integer
+ end
+end
diff --git a/db/migrate/20190912223232_add_role_to_users.rb b/db/migrate/20190912223232_add_role_to_users.rb
new file mode 100644
index 00000000000..afbd78ed509
--- /dev/null
+++ b/db/migrate/20190912223232_add_role_to_users.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddRoleToUsers < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :users, :role, :smallint
+ end
+end
diff --git a/db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb b/db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb
new file mode 100644
index 00000000000..66cd450895c
--- /dev/null
+++ b/db/migrate/20190913174707_add_spdx_id_to_software_licenses.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddSpdxIdToSoftwareLicenses < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :software_licenses, :spdx_identifier, :string, limit: 255
+ end
+
+ def down
+ remove_column :software_licenses, :spdx_identifier
+ end
+end
diff --git a/db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb b/db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb
new file mode 100644
index 00000000000..94f8738b0cc
--- /dev/null
+++ b/db/migrate/20190913175827_add_index_to_software_licenses_on_spdx_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToSoftwareLicensesOnSpdxId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :software_licenses, :spdx_identifier
+ end
+
+ def down
+ remove_concurrent_index :software_licenses, :spdx_identifier
+ end
+end
diff --git a/db/migrate/20190918025618_add_user_and_timestamps_to_design_management_versions.rb b/db/migrate/20190918025618_add_user_and_timestamps_to_design_management_versions.rb
new file mode 100644
index 00000000000..3daca8a8e97
--- /dev/null
+++ b/db/migrate/20190918025618_add_user_and_timestamps_to_design_management_versions.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddUserAndTimestampsToDesignManagementVersions < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ add_column :design_management_versions, :user_id, :integer
+ add_column :design_management_versions, :created_at, :datetime_with_timezone
+ end
+
+ def down
+ remove_columns :design_management_versions, :user_id, :created_at
+ end
+end
diff --git a/db/migrate/20190918102042_create_grafana_integrations.rb b/db/migrate/20190918102042_create_grafana_integrations.rb
new file mode 100644
index 00000000000..aac27d129db
--- /dev/null
+++ b/db/migrate/20190918102042_create_grafana_integrations.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateGrafanaIntegrations < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :grafana_integrations do |t|
+ t.references :project, index: true, foreign_key: { on_delete: :cascade }, unique: true, null: false
+ t.timestamps_with_timezone null: false
+ t.string :encrypted_token, limit: 255, null: false
+ t.string :encrypted_token_iv, limit: 255, null: false
+ t.string :grafana_url, null: false, limit: 1024
+ end
+ end
+end
diff --git a/db/migrate/20190919040324_add_successfull_pages_deploy_partial_index_on_ci_builds.rb b/db/migrate/20190919040324_add_successfull_pages_deploy_partial_index_on_ci_builds.rb
new file mode 100644
index 00000000000..d736b21dddf
--- /dev/null
+++ b/db/migrate/20190919040324_add_successfull_pages_deploy_partial_index_on_ci_builds.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddSuccessfullPagesDeployPartialIndexOnCiBuilds < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_ci_builds_on_project_id_for_successfull_pages_deploy'
+
+ def up
+ add_concurrent_index(
+ :ci_builds, :project_id,
+ name: INDEX_NAME,
+ where: "type='GenericCommitStatus' AND stage='deploy' AND name='pages:deploy' AND status = 'success'"
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_builds, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20190919091300_create_evidences.rb b/db/migrate/20190919091300_create_evidences.rb
new file mode 100644
index 00000000000..3f861ed26bd
--- /dev/null
+++ b/db/migrate/20190919091300_create_evidences.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateEvidences < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :evidences do |t|
+ t.references :release, foreign_key: { on_delete: :cascade }, null: false
+ t.timestamps_with_timezone
+ t.binary :summary_sha
+ t.jsonb :summary, null: false, default: {}
+ end
+ end
+end
diff --git a/db/migrate/20190919104119_index_timestamp_columns_for_merge_requests_creation_date.rb b/db/migrate/20190919104119_index_timestamp_columns_for_merge_requests_creation_date.rb
new file mode 100644
index 00000000000..5e0d80630cd
--- /dev/null
+++ b/db/migrate/20190919104119_index_timestamp_columns_for_merge_requests_creation_date.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class IndexTimestampColumnsForMergeRequestsCreationDate < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(*index_arguments)
+ end
+
+ def down
+ remove_concurrent_index(*index_arguments)
+ end
+
+ private
+
+ def index_arguments
+ [
+ :merge_requests,
+ [:target_project_id, :created_at],
+ {
+ name: 'index_merge_requests_target_project_id_created_at'
+ }
+ ]
+ end
+end
diff --git a/db/migrate/20190919162036_add_index_to_clusters_providers_gcp_on_cloud_run.rb b/db/migrate/20190919162036_add_index_to_clusters_providers_gcp_on_cloud_run.rb
new file mode 100644
index 00000000000..8e0bde97cc1
--- /dev/null
+++ b/db/migrate/20190919162036_add_index_to_clusters_providers_gcp_on_cloud_run.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToClustersProvidersGcpOnCloudRun < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:cluster_providers_gcp, :cloud_run)
+ end
+
+ def down
+ remove_concurrent_index(:cluster_providers_gcp, :cloud_run)
+ end
+end
diff --git a/db/migrate/20190919183411_add_index_packages_on_name_trigram_to_packages_packages.rb b/db/migrate/20190919183411_add_index_packages_on_name_trigram_to_packages_packages.rb
new file mode 100644
index 00000000000..d359350a891
--- /dev/null
+++ b/db/migrate/20190919183411_add_index_packages_on_name_trigram_to_packages_packages.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexPackagesOnNameTrigramToPackagesPackages < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_packages_packages_on_name_trigram'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :packages_packages, :name, name: INDEX_NAME, using: :gin, opclass: { name: :gin_trgm_ops }
+ end
+
+ def down
+ remove_concurrent_index_by_name(:packages_packages, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb b/db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb
new file mode 100644
index 00000000000..f8f1c6c231b
--- /dev/null
+++ b/db/migrate/20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class BackfillReleasesTableUpdatedAtAndAddNotNullConstraintsToTimestamps < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ change_column_null(:releases, :created_at, false, Time.zone.now)
+
+ update_column_in_batches(:releases, :updated_at, Arel.sql('created_at')) do |table, query|
+ query.where(table[:updated_at].eq(nil))
+ end
+
+ change_column_null(:releases, :updated_at, false, Time.zone.now)
+ end
+
+ def down
+ change_column_null(:releases, :updated_at, true)
+ change_column_null(:releases, :created_at, true)
+ end
+end
diff --git a/db/migrate/20190924124627_add_pull_mirror_branch_prefix_to_projects.rb b/db/migrate/20190924124627_add_pull_mirror_branch_prefix_to_projects.rb
new file mode 100644
index 00000000000..b9f729d7d66
--- /dev/null
+++ b/db/migrate/20190924124627_add_pull_mirror_branch_prefix_to_projects.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddPullMirrorBranchPrefixToProjects < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :projects, :pull_mirror_branch_prefix, :string, limit: 50
+ end
+end
diff --git a/db/migrate/20190925055714_default_request_access_groups.rb b/db/migrate/20190925055714_default_request_access_groups.rb
new file mode 100644
index 00000000000..ba3efbe56f4
--- /dev/null
+++ b/db/migrate/20190925055714_default_request_access_groups.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DefaultRequestAccessGroups < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ change_column_default :namespaces, :request_access_enabled, true
+ end
+
+ def down
+ change_column_default :namespaces, :request_access_enabled, false
+ end
+end
diff --git a/db/migrate/20190925055902_default_request_access_projects.rb b/db/migrate/20190925055902_default_request_access_projects.rb
new file mode 100644
index 00000000000..3ad88d0963d
--- /dev/null
+++ b/db/migrate/20190925055902_default_request_access_projects.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class DefaultRequestAccessProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ change_column_default :projects, :request_access_enabled, true
+ end
+
+ def down
+ change_column_default :projects, :request_access_enabled, false
+ end
+end
diff --git a/db/migrate/20190926041216_add_user_indexes_to_design_management_versions.rb b/db/migrate/20190926041216_add_user_indexes_to_design_management_versions.rb
new file mode 100644
index 00000000000..6eb9fdbbcaa
--- /dev/null
+++ b/db/migrate/20190926041216_add_user_indexes_to_design_management_versions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddUserIndexesToDesignManagementVersions < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :design_management_versions, :users, column: :user_id, on_delete: :nullify
+ add_concurrent_index :design_management_versions, :user_id, where: 'user_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :design_management_versions, :user_id
+ remove_foreign_key :design_management_versions, column: :user_id
+ end
+end
diff --git a/db/migrate/20190927055500_create_description_versions.rb b/db/migrate/20190927055500_create_description_versions.rb
new file mode 100644
index 00000000000..6ad34d4a89e
--- /dev/null
+++ b/db/migrate/20190927055500_create_description_versions.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class CreateDescriptionVersions < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ create_table :description_versions do |t|
+ t.timestamps_with_timezone
+ t.references :issue, index: false, foreign_key: { on_delete: :cascade }, type: :integer
+ t.references :merge_request, index: false, foreign_key: { on_delete: :cascade }, type: :integer
+ t.references :epic, index: false, foreign_key: { on_delete: :cascade }, type: :integer
+ t.text :description
+ end
+
+ add_index :description_versions, :issue_id, where: 'issue_id IS NOT NULL'
+ add_index :description_versions, :merge_request_id, where: 'merge_request_id IS NOT NULL'
+ add_index :description_versions, :epic_id, where: 'epic_id IS NOT NULL'
+
+ add_column :system_note_metadata, :description_version_id, :bigint
+ end
+
+ def down
+ remove_column :system_note_metadata, :description_version_id
+
+ drop_table :description_versions
+ end
+end
diff --git a/db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb b/db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb
new file mode 100644
index 00000000000..695ba955043
--- /dev/null
+++ b/db/migrate/20190927055540_add_index_to_sytem_note_metadata_description_version_id.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexToSytemNoteMetadataDescriptionVersionId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :system_note_metadata, :description_version_id, unique: true, where: 'description_version_id IS NOT NULL'
+ add_concurrent_foreign_key :system_note_metadata, :description_versions, column: :description_version_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key :system_note_metadata, column: :description_version_id
+ remove_concurrent_index :system_note_metadata, :description_version_id
+ end
+end
diff --git a/db/migrate/20190927074328_add_index_on_snippet_content.rb b/db/migrate/20190927074328_add_index_on_snippet_content.rb
new file mode 100644
index 00000000000..ef7583508f2
--- /dev/null
+++ b/db/migrate/20190927074328_add_index_on_snippet_content.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnSnippetContent < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_snippets_on_content_trigram'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :snippets, :content, name: INDEX_NAME, using: :gin, opclass: { content: :gin_trgm_ops }
+ end
+
+ def down
+ remove_concurrent_index_by_name(:snippets, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20190929180751_create_vulnerabilities.rb b/db/migrate/20190929180751_create_vulnerabilities.rb
new file mode 100644
index 00000000000..aea018c5979
--- /dev/null
+++ b/db/migrate/20190929180751_create_vulnerabilities.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class CreateVulnerabilities < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :vulnerabilities do |t|
+ t.bigint "milestone_id"
+ t.bigint "epic_id"
+ t.bigint "project_id", null: false
+ t.bigint "author_id", null: false
+ t.bigint "updated_by_id"
+ t.bigint "last_edited_by_id"
+ t.bigint "start_date_sourcing_milestone_id"
+ t.bigint "due_date_sourcing_milestone_id"
+ t.bigint "closed_by_id"
+ t.datetime_with_timezone "last_edited_at"
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.datetime_with_timezone "closed_at"
+ t.date "start_date"
+ t.date "due_date"
+ t.integer "state", limit: 2, default: 1, null: false # initially: open, closed
+ t.integer "severity", limit: 2, null: false # auto-calculated as highest-severity finding, but overrideable
+ t.integer "confidence", limit: 2, null: false # auto-calculated as lowest-confidence finding, but overrideable
+ t.boolean "severity_overridden", default: false
+ t.boolean "confidence_overridden", default: false
+ t.string "title", limit: 255, null: false
+ t.text "title_html", null: false
+ t.text "description"
+ t.text "description_html"
+ end
+ end
+end
diff --git a/db/migrate/20190929180813_add_reference_from_vulnerability_occurrences_to_occurrences.rb b/db/migrate/20190929180813_add_reference_from_vulnerability_occurrences_to_occurrences.rb
new file mode 100644
index 00000000000..eb8e8fb73d1
--- /dev/null
+++ b/db/migrate/20190929180813_add_reference_from_vulnerability_occurrences_to_occurrences.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddReferenceFromVulnerabilityOccurrencesToOccurrences < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerability_occurrences, :vulnerability_id, :bigint
+ end
+end
diff --git a/db/migrate/20190929180827_add_foreign_keys_and_indexes_to_vulnerabilities.rb b/db/migrate/20190929180827_add_foreign_keys_and_indexes_to_vulnerabilities.rb
new file mode 100644
index 00000000000..4d7c2363083
--- /dev/null
+++ b/db/migrate/20190929180827_add_foreign_keys_and_indexes_to_vulnerabilities.rb
@@ -0,0 +1,76 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddForeignKeysAndIndexesToVulnerabilities < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerabilities, :milestone_id
+ add_concurrent_foreign_key :vulnerabilities, :milestones, column: :milestone_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :epic_id
+ add_concurrent_foreign_key :vulnerabilities, :epics, column: :epic_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :project_id
+ add_concurrent_foreign_key :vulnerabilities, :projects, column: :project_id
+
+ add_concurrent_index :vulnerabilities, :author_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :author_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :updated_by_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :updated_by_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :last_edited_by_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :last_edited_by_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :closed_by_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :closed_by_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :start_date_sourcing_milestone_id
+ add_concurrent_foreign_key :vulnerabilities, :milestones, column: :start_date_sourcing_milestone_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerabilities, :due_date_sourcing_milestone_id
+ add_concurrent_foreign_key :vulnerabilities, :milestones, column: :due_date_sourcing_milestone_id, on_delete: :nullify
+
+ add_concurrent_index :vulnerability_occurrences, :vulnerability_id
+ add_concurrent_foreign_key :vulnerability_occurrences, :vulnerabilities, column: :vulnerability_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key :vulnerability_occurrences, :vulnerabilities
+ remove_concurrent_index :vulnerability_occurrences, :vulnerability_id
+
+ remove_foreign_key :vulnerabilities, column: :due_date_sourcing_milestone_id
+ remove_concurrent_index :vulnerabilities, :due_date_sourcing_milestone_id
+
+ remove_foreign_key :vulnerabilities, column: :start_date_sourcing_milestone_id
+ remove_concurrent_index :vulnerabilities, :start_date_sourcing_milestone_id
+
+ remove_foreign_key :vulnerabilities, column: :closed_by_id
+ remove_concurrent_index :vulnerabilities, :closed_by_id
+
+ remove_foreign_key :vulnerabilities, column: :last_edited_by_id
+ remove_concurrent_index :vulnerabilities, :last_edited_by_id
+
+ remove_foreign_key :vulnerabilities, column: :updated_by_id
+ remove_concurrent_index :vulnerabilities, :updated_by_id
+
+ remove_foreign_key :vulnerabilities, column: :author_id
+ remove_concurrent_index :vulnerabilities, :author_id
+
+ remove_foreign_key :vulnerabilities, :projects
+ remove_concurrent_index :vulnerabilities, :project_id
+
+ remove_foreign_key :vulnerabilities, :epics
+ remove_concurrent_index :vulnerabilities, :epic_id
+
+ remove_foreign_key :vulnerabilities, :milestones
+ remove_concurrent_index :vulnerabilities, :milestone_id
+ end
+end
diff --git a/db/migrate/20190930025655_add_incident_management_throttle_columns_to_application_setting.rb b/db/migrate/20190930025655_add_incident_management_throttle_columns_to_application_setting.rb
new file mode 100644
index 00000000000..577c705fbef
--- /dev/null
+++ b/db/migrate/20190930025655_add_incident_management_throttle_columns_to_application_setting.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class AddIncidentManagementThrottleColumnsToApplicationSetting < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def up
+ add_column(:application_settings,
+ :throttle_incident_management_notification_enabled,
+ :boolean,
+ null: false,
+ default: false)
+
+ add_column(:application_settings,
+ :throttle_incident_management_notification_period_in_seconds,
+ :integer,
+ default: 3_600)
+
+ add_column(:application_settings,
+ :throttle_incident_management_notification_per_period,
+ :integer,
+ default: 3_600)
+ end
+
+ def down
+ remove_column :application_settings, :throttle_incident_management_notification_enabled
+ remove_column :application_settings, :throttle_incident_management_notification_period_in_seconds
+ remove_column :application_settings, :throttle_incident_management_notification_per_period
+ end
+end
diff --git a/db/migrate/20190930063627_add_management_project_id_to_clusters.rb b/db/migrate/20190930063627_add_management_project_id_to_clusters.rb
new file mode 100644
index 00000000000..46c3fef8e76
--- /dev/null
+++ b/db/migrate/20190930063627_add_management_project_id_to_clusters.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddManagementProjectIdToClusters < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :clusters, :management_project_id, :integer
+ end
+end
diff --git a/db/migrate/20190930082942_add_new_release_to_notification_settings.rb b/db/migrate/20190930082942_add_new_release_to_notification_settings.rb
new file mode 100644
index 00000000000..2ec5815f542
--- /dev/null
+++ b/db/migrate/20190930082942_add_new_release_to_notification_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNewReleaseToNotificationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :notification_settings, :new_release, :boolean
+ end
+end
diff --git a/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb b/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb
new file mode 100644
index 00000000000..97253dd1f2d
--- /dev/null
+++ b/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddManagementProjectIdIndexFkToClusters < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :clusters, :projects, column: :management_project_id, on_delete: :nullify
+ add_concurrent_index :clusters, :management_project_id, where: 'management_project_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :clusters, :management_project_id
+ remove_foreign_key_if_exists :clusters, column: :management_project_id
+ end
+end
diff --git a/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb b/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
new file mode 100644
index 00000000000..94d16e921df
--- /dev/null
+++ b/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ create_table :self_managed_prometheus_alert_events do |t|
+ t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
+ t.references :environment, index: true, foreign_key: { on_delete: :cascade }
+ t.datetime_with_timezone :started_at, null: false
+ t.datetime_with_timezone :ended_at
+
+ t.integer :status, null: false, limit: 2
+ t.string :title, null: false, limit: 255
+ t.string :query_expression, limit: 255
+ t.string :payload_key, null: false, limit: 255
+ t.index [:project_id, :payload_key], unique: true, name: 'idx_project_id_payload_key_self_managed_prometheus_alert_events'
+ end
+ end
+end
diff --git a/db/migrate/20191003060227_add_push_event_hooks_limit_to_application_settings.rb b/db/migrate/20191003060227_add_push_event_hooks_limit_to_application_settings.rb
new file mode 100644
index 00000000000..f107181bbde
--- /dev/null
+++ b/db/migrate/20191003060227_add_push_event_hooks_limit_to_application_settings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddPushEventHooksLimitToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:application_settings, :push_event_hooks_limit, :integer, default: 3)
+ end
+
+ def down
+ remove_column(:application_settings, :push_event_hooks_limit)
+ end
+end
diff --git a/db/migrate/20191003064615_create_aws_roles.rb b/db/migrate/20191003064615_create_aws_roles.rb
new file mode 100644
index 00000000000..ee35953f558
--- /dev/null
+++ b/db/migrate/20191003064615_create_aws_roles.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class CreateAwsRoles < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :aws_roles, id: false do |t|
+ t.references :user, primary_key: true, default: nil, type: :integer, index: { unique: true }, foreign_key: { on_delete: :cascade }
+
+ t.timestamps_with_timezone null: false
+
+ t.string :role_arn, null: false, limit: 2048
+ t.string :role_external_id, null: false, limit: 64
+
+ t.index :role_external_id, unique: true
+ end
+ end
+end
diff --git a/db/migrate/20191004133612_create_analytics_repository_file_commits.rb b/db/migrate/20191004133612_create_analytics_repository_file_commits.rb
new file mode 100644
index 00000000000..f2064b2b301
--- /dev/null
+++ b/db/migrate/20191004133612_create_analytics_repository_file_commits.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateAnalyticsRepositoryFileCommits < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :analytics_repository_file_commits do |t|
+ t.references :analytics_repository_file, index: { name: 'index_analytics_repository_file_commits_file_id' }, foreign_key: { on_delete: :cascade }, null: false
+ t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
+ t.date :committed_date, null: false
+ t.integer :commit_count, limit: 2, null: false
+ end
+
+ add_index :analytics_repository_file_commits,
+ [:project_id, :committed_date, :analytics_repository_file_id],
+ name: 'index_file_commits_on_committed_date_file_id_and_project_id',
+ unique: true
+ end
+end
diff --git a/db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb b/db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb
new file mode 100644
index 00000000000..84befc95d00
--- /dev/null
+++ b/db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddPushEventActivitiesLimitToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:application_settings, :push_event_activities_limit, :integer, default: 3)
+ end
+
+ def down
+ remove_column(:application_settings, :push_event_activities_limit)
+ end
+end
diff --git a/db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb b/db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb
new file mode 100644
index 00000000000..72621971dbb
--- /dev/null
+++ b/db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddRefCountToPushEventPayloads < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :push_event_payloads, :ref_count, :integer
+ end
+end
diff --git a/db/migrate/20191008180203_add_issuable_state_id_indexes.rb b/db/migrate/20191008180203_add_issuable_state_id_indexes.rb
new file mode 100644
index 00000000000..a9a8b8b6359
--- /dev/null
+++ b/db/migrate/20191008180203_add_issuable_state_id_indexes.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+class AddIssuableStateIdIndexes < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # Creates the same indexes that are currently using state:string column
+ # for issues and merge_requests tables
+ create_indexes_for_issues
+ create_indexes_for_merge_requests
+ end
+
+ def down
+ # Removes indexes for issues
+ remove_concurrent_index_by_name :issues, 'idx_issues_on_state_id'
+ remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_created_at_and_id_and_state_id'
+ remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_due_date_and_id_and_state_id'
+ remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_rel_position_and_state_id_and_id'
+ remove_concurrent_index_by_name :issues, 'idx_issues_on_project_id_and_updated_at_and_id_and_state_id'
+
+ # Removes indexes from merge_requests
+ remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_id_and_merge_jid'
+ remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_source_project_and_branch_state_opened'
+ remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_state_id_and_merge_status'
+ remove_concurrent_index_by_name :merge_requests, 'idx_merge_requests_on_target_project_id_and_iid_opened'
+ end
+
+ def create_indexes_for_issues
+ add_concurrent_index :issues, :state_id, name: 'idx_issues_on_state_id'
+
+ add_concurrent_index :issues,
+ [:project_id, :created_at, :id, :state_id],
+ name: 'idx_issues_on_project_id_and_created_at_and_id_and_state_id'
+
+ add_concurrent_index :issues,
+ [:project_id, :due_date, :id, :state_id],
+ where: 'due_date IS NOT NULL',
+ name: 'idx_issues_on_project_id_and_due_date_and_id_and_state_id'
+
+ add_concurrent_index :issues,
+ [:project_id, :relative_position, :state_id, :id],
+ order: { id: :desc },
+ name: 'idx_issues_on_project_id_and_rel_position_and_state_id_and_id'
+
+ add_concurrent_index :issues,
+ [:project_id, :updated_at, :id, :state_id],
+ name: 'idx_issues_on_project_id_and_updated_at_and_id_and_state_id'
+ end
+
+ def create_indexes_for_merge_requests
+ add_concurrent_index :merge_requests,
+ [:id, :merge_jid],
+ where: 'merge_jid IS NOT NULL and state_id = 4',
+ name: 'idx_merge_requests_on_id_and_merge_jid'
+
+ add_concurrent_index :merge_requests,
+ [:source_project_id, :source_branch],
+ where: 'state_id = 1',
+ name: 'idx_merge_requests_on_source_project_and_branch_state_opened'
+
+ add_concurrent_index :merge_requests,
+ [:state_id, :merge_status],
+ where: "state_id = 1 AND merge_status = 'can_be_merged'",
+ name: 'idx_merge_requests_on_state_id_and_merge_status'
+
+ add_concurrent_index :merge_requests,
+ [:target_project_id, :iid],
+ where: 'state_id = 1',
+ name: 'idx_merge_requests_on_target_project_id_and_iid_opened'
+ end
+end
diff --git a/db/migrate/20191008200204_add_state_id_default_value.rb b/db/migrate/20191008200204_add_state_id_default_value.rb
new file mode 100644
index 00000000000..15a80163ca8
--- /dev/null
+++ b/db/migrate/20191008200204_add_state_id_default_value.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddStateIdDefaultValue < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ change_column_default :issues, :state_id, 1
+ change_column_null :issues, :state_id, false
+ change_column_default :merge_requests, :state_id, 1
+ change_column_null :merge_requests, :state_id, false
+ end
+
+ def down
+ change_column_default :issues, :state_id, nil
+ change_column_null :issues, :state_id, true
+ change_column_default :merge_requests, :state_id, nil
+ change_column_null :merge_requests, :state_id, true
+ end
+end
diff --git a/db/migrate/20191009222222_add_custom_http_clone_url_root_to_application_settings.rb b/db/migrate/20191009222222_add_custom_http_clone_url_root_to_application_settings.rb
new file mode 100644
index 00000000000..0fa8ff449f7
--- /dev/null
+++ b/db/migrate/20191009222222_add_custom_http_clone_url_root_to_application_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddCustomHttpCloneUrlRootToApplicationSettings < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :custom_http_clone_url_root, :string, limit: 511
+ end
+end
diff --git a/db/migrate/20191014084150_add_index_on_snippets_project_id_and_visibility_level.rb b/db/migrate/20191014084150_add_index_on_snippets_project_id_and_visibility_level.rb
new file mode 100644
index 00000000000..a8f40953e5d
--- /dev/null
+++ b/db/migrate/20191014084150_add_index_on_snippets_project_id_and_visibility_level.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnSnippetsProjectIdAndVisibilityLevel < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :snippets, [:project_id, :visibility_level]
+ end
+
+ def down
+ remove_concurrent_index :snippets, [:project_id, :visibility_level]
+ end
+end
diff --git a/db/migrate/20191014132931_remove_index_on_snippets_project_id.rb b/db/migrate/20191014132931_remove_index_on_snippets_project_id.rb
new file mode 100644
index 00000000000..a1d3ffdb8c8
--- /dev/null
+++ b/db/migrate/20191014132931_remove_index_on_snippets_project_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RemoveIndexOnSnippetsProjectId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index :snippets, [:project_id]
+ end
+
+ def down
+ add_concurrent_index :snippets, [:project_id]
+ end
+end
diff --git a/db/migrate/20191016072826_replace_ci_trigger_requests_index.rb b/db/migrate/20191016072826_replace_ci_trigger_requests_index.rb
new file mode 100644
index 00000000000..d7c9524806e
--- /dev/null
+++ b/db/migrate/20191016072826_replace_ci_trigger_requests_index.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ReplaceCiTriggerRequestsIndex < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_trigger_requests, [:trigger_id, :id], order: { id: :desc }
+
+ remove_concurrent_index :ci_trigger_requests, [:trigger_id]
+ end
+
+ def down
+ add_concurrent_index :ci_trigger_requests, [:trigger_id]
+
+ remove_concurrent_index :ci_trigger_requests, [:trigger_id, :id], order: { id: :desc }
+ end
+end
diff --git a/db/migrate/20191016220135_add_join_table_for_self_managed_prometheus_alert_issues.rb b/db/migrate/20191016220135_add_join_table_for_self_managed_prometheus_alert_issues.rb
new file mode 100644
index 00000000000..68b448f8836
--- /dev/null
+++ b/db/migrate/20191016220135_add_join_table_for_self_managed_prometheus_alert_issues.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddJoinTableForSelfManagedPrometheusAlertIssues < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ # Join table to Issues
+ create_table :issues_self_managed_prometheus_alert_events, id: false do |t|
+ t.references :issue, null: false,
+ index: false, # Uses the index below
+ foreign_key: { on_delete: :cascade }
+ t.references :self_managed_prometheus_alert_event, null: false,
+ index: { name: 'issue_id_issues_self_managed_rometheus_alert_events_index' },
+ foreign_key: { on_delete: :cascade }
+
+ t.timestamps_with_timezone
+ t.index [:issue_id, :self_managed_prometheus_alert_event_id],
+ unique: true, name: 'issue_id_self_managed_prometheus_alert_event_id_index'
+ end
+ end
+end