summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20180215181245_users_name_lower_index.rb6
-rw-r--r--db/migrate/20180504195842_project_name_lower_index.rb6
-rw-r--r--db/migrate/20180902070406_create_group_group_links.rb32
-rw-r--r--db/migrate/20190703171157_add_sourcing_epic_dates.rb10
-rw-r--r--db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb25
-rw-r--r--db/migrate/20190805140353_remove_rendundant_index_from_releases.rb7
-rw-r--r--db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb21
-rw-r--r--db/migrate/20190910211526_create_packages_conan_file_metadata.rb18
-rw-r--r--db/migrate/20190918104731_add_cleanup_status_to_cluster.rb21
-rw-r--r--db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb12
-rw-r--r--db/migrate/20190930153535_create_zoom_meetings.rb24
-rw-r--r--db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb22
-rw-r--r--db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb1
-rw-r--r--db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb11
-rw-r--r--db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb19
-rw-r--r--db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb15
-rw-r--r--db/migrate/20191003195620_add_pendo_url_to_application_settings.rb9
-rw-r--r--db/migrate/20191004080818_add_productivity_analytics_start_date.rb11
-rw-r--r--db/migrate/20191004081520_fill_productivity_analytics_start_date.rb31
-rw-r--r--db/migrate/20191009100244_add_geo_design_repository_counters.rb16
-rw-r--r--db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb13
-rw-r--r--db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb17
-rw-r--r--db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb9
-rw-r--r--db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb11
-rw-r--r--db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb9
-rw-r--r--db/migrate/20191014025629_rename_design_management_version_user_to_author.rb17
-rw-r--r--db/migrate/20191014030730_add_author_index_to_design_management_versions.rb17
-rw-r--r--db/migrate/20191016133352_create_ci_subscriptions_projects.rb21
-rw-r--r--db/migrate/20191017001326_create_users_security_dashboard_projects.rb15
-rw-r--r--db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb17
-rw-r--r--db/migrate/20191017134513_add_deployment_merge_requests.rb33
-rw-r--r--db/migrate/20191017191341_create_clusters_applications_crossplane.rb19
-rw-r--r--db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb19
-rw-r--r--db/migrate/20191023152913_add_default_and_free_plans.rb29
-rw-r--r--db/migrate/20191024134020_add_index_to_zoom_meetings.rb17
-rw-r--r--db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb15
-rw-r--r--db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb9
-rw-r--r--db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb17
-rw-r--r--db/migrate/20191029125305_create_packages_conan_metadata.rb16
-rw-r--r--db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb23
-rw-r--r--db/migrate/20191030135044_create_plan_limits.rb14
-rw-r--r--db/migrate/20191030152934_move_limits_from_plans.rb17
-rw-r--r--db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb19
-rw-r--r--db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb14
-rw-r--r--db/migrate/20191104205020_add_license_details_to_application_settings.rb11
-rw-r--r--db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb9
-rw-r--r--db/migrate/20191105193652_add_index_on_deployments_updated_at.rb18
-rw-r--r--db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb17
-rw-r--r--db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb17
-rw-r--r--db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb9
-rw-r--r--db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb19
-rw-r--r--db/migrate/20191111121500_default_ci_config_path.rb13
-rw-r--r--db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb9
-rw-r--r--db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb19
-rw-r--r--db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb19
-rw-r--r--db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb18
-rw-r--r--db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb15
-rw-r--r--db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb19
-rw-r--r--db/migrate/20191115091425_create_vulnerability_issue_links.rb23
59 files changed, 946 insertions, 13 deletions
diff --git a/db/migrate/20180215181245_users_name_lower_index.rb b/db/migrate/20180215181245_users_name_lower_index.rb
index 3b80601a727..fa1a115a78a 100644
--- a/db/migrate/20180215181245_users_name_lower_index.rb
+++ b/db/migrate/20180215181245_users_name_lower_index.rb
@@ -20,10 +20,6 @@ class UsersNameLowerIndex < ActiveRecord::Migration[4.2]
def down
return unless Gitlab::Database.postgresql?
- if supports_drop_index_concurrently?
- execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
- else
- execute "DROP INDEX IF EXISTS #{INDEX_NAME}"
- end
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
end
end
diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb
index 3fe90c3fbb1..fa74330d5d9 100644
--- a/db/migrate/20180504195842_project_name_lower_index.rb
+++ b/db/migrate/20180504195842_project_name_lower_index.rb
@@ -22,11 +22,7 @@ class ProjectNameLowerIndex < ActiveRecord::Migration[4.2]
return unless Gitlab::Database.postgresql?
disable_statement_timeout do
- if supports_drop_index_concurrently?
- execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
- else
- execute "DROP INDEX IF EXISTS #{INDEX_NAME}"
- end
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
end
end
end
diff --git a/db/migrate/20180902070406_create_group_group_links.rb b/db/migrate/20180902070406_create_group_group_links.rb
new file mode 100644
index 00000000000..95fed0ebf96
--- /dev/null
+++ b/db/migrate/20180902070406_create_group_group_links.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CreateGroupGroupLinks < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ create_table :group_group_links do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :shared_group, null: false,
+ index: false,
+ foreign_key: { on_delete: :cascade,
+ to_table: :namespaces }
+ t.references :shared_with_group, null: false,
+ foreign_key: { on_delete: :cascade,
+ to_table: :namespaces }
+ t.date :expires_at
+ t.index [:shared_group_id, :shared_with_group_id],
+ { unique: true,
+ name: 'index_group_group_links_on_shared_group_and_shared_with_group' }
+ t.integer :group_access, { limit: 2,
+ default: 30, # Gitlab::Access::DEVELOPER
+ null: false }
+ end
+ end
+
+ def down
+ drop_table :group_group_links
+ end
+end
diff --git a/db/migrate/20190703171157_add_sourcing_epic_dates.rb b/db/migrate/20190703171157_add_sourcing_epic_dates.rb
new file mode 100644
index 00000000000..202e2098d5b
--- /dev/null
+++ b/db/migrate/20190703171157_add_sourcing_epic_dates.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddSourcingEpicDates < ActiveRecord::Migration[5.1]
+ DOWNTIME = false
+
+ def change
+ add_column :epics, :start_date_sourcing_epic_id, :integer
+ add_column :epics, :due_date_sourcing_epic_id, :integer
+ end
+end
diff --git a/db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb b/db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb
new file mode 100644
index 00000000000..4995a3cd03f
--- /dev/null
+++ b/db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddSourcingEpicDatesFks < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :epics, :start_date_sourcing_epic_id, where: 'start_date_sourcing_epic_id is not null'
+ add_concurrent_index :epics, :due_date_sourcing_epic_id, where: 'due_date_sourcing_epic_id is not null'
+
+ add_concurrent_foreign_key :epics, :epics, column: :start_date_sourcing_epic_id, on_delete: :nullify
+ add_concurrent_foreign_key :epics, :epics, column: :due_date_sourcing_epic_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :epics, column: :start_date_sourcing_epic_id
+ remove_foreign_key_if_exists :epics, column: :due_date_sourcing_epic_id
+
+ remove_concurrent_index :epics, :start_date_sourcing_epic_id
+ remove_concurrent_index :epics, :due_date_sourcing_epic_id
+ end
+end
diff --git a/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb b/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb
index fc4bc1a423b..477f8a850f8 100644
--- a/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb
+++ b/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb
@@ -12,10 +12,13 @@ class RemoveRendundantIndexFromReleases < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
- remove_concurrent_index :releases, :project_id
+ remove_concurrent_index_by_name :releases, 'index_releases_on_project_id'
+
+ # This is an extra index that is not present in db/schema.rb but known to exist on some installs
+ remove_concurrent_index_by_name :releases, 'releases_project_id_idx' if index_exists_by_name?(:releases, 'releases_project_id_idx')
end
def down
- add_concurrent_index :releases, :project_id
+ add_concurrent_index :releases, :project_id, name: 'index_releases_on_project_id'
end
end
diff --git a/db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb b/db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb
new file mode 100644
index 00000000000..e624642c2fc
--- /dev/null
+++ b/db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.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 AddSourcegraphConfigurationToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def up
+ add_column(:application_settings, :sourcegraph_enabled, :boolean, default: false, null: false)
+ add_column(:application_settings, :sourcegraph_url, :string, null: true, limit: 255)
+ end
+
+ def down
+ remove_column(:application_settings, :sourcegraph_enabled)
+ remove_column(:application_settings, :sourcegraph_url)
+ end
+end
diff --git a/db/migrate/20190910211526_create_packages_conan_file_metadata.rb b/db/migrate/20190910211526_create_packages_conan_file_metadata.rb
new file mode 100644
index 00000000000..0f8dacb72de
--- /dev/null
+++ b/db/migrate/20190910211526_create_packages_conan_file_metadata.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreatePackagesConanFileMetadata < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :packages_conan_file_metadata do |t|
+ t.references :package_file, index: { unique: true }, null: false, foreign_key: { to_table: :packages_package_files, on_delete: :cascade }, type: :bigint
+ t.timestamps_with_timezone
+ t.string "recipe_revision", null: false, default: "0", limit: 255
+ t.string "package_revision", limit: 255
+ t.string "conan_package_reference", limit: 255
+ t.integer "conan_file_type", limit: 2, null: false
+ end
+ end
+end
diff --git a/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb b/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb
new file mode 100644
index 00000000000..0ba9d8e6c89
--- /dev/null
+++ b/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddCleanupStatusToCluster < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:clusters, :cleanup_status,
+ :smallint,
+ default: 1,
+ allow_null: false)
+ end
+
+ def down
+ remove_column(:clusters, :cleanup_status)
+ end
+end
diff --git a/db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb b/db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb
new file mode 100644
index 00000000000..4e71905e3a3
--- /dev/null
+++ b/db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddCleanupStatusReasonToCluster < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :clusters, :cleanup_status_reason, :text
+ end
+end
diff --git a/db/migrate/20190930153535_create_zoom_meetings.rb b/db/migrate/20190930153535_create_zoom_meetings.rb
new file mode 100644
index 00000000000..6b92c53da79
--- /dev/null
+++ b/db/migrate/20190930153535_create_zoom_meetings.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateZoomMeetings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ ZOOM_MEETING_STATUS_ADDED = 1
+
+ def change
+ create_table :zoom_meetings do |t|
+ t.references :project, foreign_key: { on_delete: :cascade },
+ null: false
+ t.references :issue, foreign_key: { on_delete: :cascade },
+ null: false
+ t.timestamps_with_timezone null: false
+ t.integer :issue_status, limit: 2, default: 1, null: false
+ t.string :url, limit: 255
+
+ t.index [:issue_id, :issue_status], unique: true,
+ where: "issue_status = #{ZOOM_MEETING_STATUS_ADDED}"
+ end
+ end
+end
diff --git a/db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb b/db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb
new file mode 100644
index 00000000000..8910dc0d9fb
--- /dev/null
+++ b/db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb
@@ -0,0 +1,22 @@
+# 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 CreateClustersApplicationsElasticStack < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :clusters_applications_elastic_stacks do |t|
+ t.timestamps_with_timezone null: false
+ t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.integer :status, null: false
+ t.string :version, null: false, limit: 255
+ t.string :kibana_hostname, limit: 255
+ t.text :status_reason
+ t.index :cluster_id, unique: true
+ end
+ end
+end
diff --git a/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb b/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
index 94d16e921df..71d10153422 100644
--- a/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
+++ b/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2]
- # Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
diff --git a/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb b/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb
new file mode 100644
index 00000000000..86d581a4383
--- /dev/null
+++ b/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddMarkForDeletionToProjects < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :projects, :marked_for_deletion_at, :date
+ add_column :projects, :marked_for_deletion_by_user_id, :integer
+ end
+end
diff --git a/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb b/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb
new file mode 100644
index 00000000000..d6ef6509fff
--- /dev/null
+++ b/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddMarkForDeletionIndexesToProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :projects, :users, column: :marked_for_deletion_by_user_id, on_delete: :nullify
+ add_concurrent_index :projects, :marked_for_deletion_by_user_id, where: 'marked_for_deletion_by_user_id IS NOT NULL'
+ end
+
+ def down
+ remove_foreign_key_if_exists :projects, column: :marked_for_deletion_by_user_id
+ remove_concurrent_index :projects, :marked_for_deletion_by_user_id
+ end
+end
diff --git a/db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb b/db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb
new file mode 100644
index 00000000000..c5f5a8cd70c
--- /dev/null
+++ b/db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb
@@ -0,0 +1,15 @@
+class AddPendoEnabledToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :application_settings, :pendo_enabled, :boolean, default: false, allow_null: false
+ end
+
+ def down
+ remove_column :application_settings, :pendo_enabled
+ end
+end
diff --git a/db/migrate/20191003195620_add_pendo_url_to_application_settings.rb b/db/migrate/20191003195620_add_pendo_url_to_application_settings.rb
new file mode 100644
index 00000000000..cc0895f8bee
--- /dev/null
+++ b/db/migrate/20191003195620_add_pendo_url_to_application_settings.rb
@@ -0,0 +1,9 @@
+class AddPendoUrlToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :pendo_url, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191004080818_add_productivity_analytics_start_date.rb b/db/migrate/20191004080818_add_productivity_analytics_start_date.rb
new file mode 100644
index 00000000000..287b0755bc1
--- /dev/null
+++ b/db/migrate/20191004080818_add_productivity_analytics_start_date.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddProductivityAnalyticsStartDate < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :productivity_analytics_start_date, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20191004081520_fill_productivity_analytics_start_date.rb b/db/migrate/20191004081520_fill_productivity_analytics_start_date.rb
new file mode 100644
index 00000000000..9432cd68708
--- /dev/null
+++ b/db/migrate/20191004081520_fill_productivity_analytics_start_date.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+# Expected migration duration: 1 minute
+class FillProductivityAnalyticsStartDate < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_request_metrics, :merged_at,
+ where: "merged_at > '2019-09-01' AND commits_count IS NOT NULL",
+ name: 'fill_productivity_analytics_start_date_tmp_index'
+
+ execute(
+ <<SQL
+ UPDATE application_settings
+ SET productivity_analytics_start_date = COALESCE((SELECT MIN(merged_at) FROM merge_request_metrics
+ WHERE merged_at > '2019-09-01' AND commits_count IS NOT NULL), NOW())
+SQL
+ )
+
+ remove_concurrent_index :merge_request_metrics, :merged_at,
+ name: 'fill_productivity_analytics_start_date_tmp_index'
+ end
+
+ def down
+ execute('UPDATE application_settings SET productivity_analytics_start_date = NULL')
+ end
+end
diff --git a/db/migrate/20191009100244_add_geo_design_repository_counters.rb b/db/migrate/20191009100244_add_geo_design_repository_counters.rb
new file mode 100644
index 00000000000..26387453f88
--- /dev/null
+++ b/db/migrate/20191009100244_add_geo_design_repository_counters.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddGeoDesignRepositoryCounters < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_table :geo_node_statuses do |t|
+ t.column :design_repositories_count, :integer
+ t.column :design_repositories_synced_count, :integer
+ t.column :design_repositories_failed_count, :integer
+ t.column :design_repositories_registry_count, :integer
+ end
+ end
+end
diff --git a/db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb b/db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb
new file mode 100644
index 00000000000..86c3c540e5e
--- /dev/null
+++ b/db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddHasExposedArtifactsToCiBuildsMetadata < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :ci_builds_metadata, :has_exposed_artifacts, :boolean
+ end
+
+ def down
+ remove_column :ci_builds_metadata, :has_exposed_artifacts
+ end
+end
diff --git a/db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb b/db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb
new file mode 100644
index 00000000000..6b8c452a62a
--- /dev/null
+++ b/db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToCiBuildsMetadataHasExposedArtifacts < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_builds_metadata, [:build_id], where: "has_exposed_artifacts IS TRUE", name: 'index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts'
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_builds_metadata, 'index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts'
+ end
+end
diff --git a/db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb b/db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb
new file mode 100644
index 00000000000..a40ce8dbee5
--- /dev/null
+++ b/db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSnowplowIgluRegistryUrlToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :snowplow_iglu_registry_url, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb b/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb
new file mode 100644
index 00000000000..79546e33253
--- /dev/null
+++ b/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddProjectDeletionAdjournedPeriodToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ DEFAULT_NUMBER_OF_DAYS_BEFORE_REMOVAL = 7
+
+ def change
+ add_column :application_settings, :deletion_adjourned_period, :integer, default: DEFAULT_NUMBER_OF_DAYS_BEFORE_REMOVAL, null: false
+ end
+end
diff --git a/db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb b/db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb
new file mode 100644
index 00000000000..0a58f0a89aa
--- /dev/null
+++ b/db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSquashCommitShaToMergeRequests < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :merge_requests, :squash_commit_sha, :binary
+ end
+end
diff --git a/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb b/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb
new file mode 100644
index 00000000000..2359cc2e826
--- /dev/null
+++ b/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenameDesignManagementVersionUserToAuthor < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :design_management_versions, :user_id, :author_id
+ end
+
+ def down
+ undo_rename_column_concurrently :design_management_versions, :user_id, :author_id
+ end
+end
diff --git a/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb b/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb
new file mode 100644
index 00000000000..30e076f1fe6
--- /dev/null
+++ b/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddAuthorIndexToDesignManagementVersions < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :design_management_versions, :author_id, where: 'author_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :design_management_versions, :author_id
+ end
+end
diff --git a/db/migrate/20191016133352_create_ci_subscriptions_projects.rb b/db/migrate/20191016133352_create_ci_subscriptions_projects.rb
new file mode 100644
index 00000000000..00ab2c19193
--- /dev/null
+++ b/db/migrate/20191016133352_create_ci_subscriptions_projects.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 CreateCiSubscriptionsProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ create_table :ci_subscriptions_projects do |t|
+ t.references :downstream_project, null: false, index: false, foreign_key: { to_table: :projects, on_delete: :cascade }
+ t.references :upstream_project, null: false, foreign_key: { to_table: :projects, on_delete: :cascade }
+ end
+
+ add_index :ci_subscriptions_projects, [:downstream_project_id, :upstream_project_id],
+ unique: true, name: 'index_ci_subscriptions_projects_unique_subscription'
+ end
+end
diff --git a/db/migrate/20191017001326_create_users_security_dashboard_projects.rb b/db/migrate/20191017001326_create_users_security_dashboard_projects.rb
new file mode 100644
index 00000000000..398401dbee6
--- /dev/null
+++ b/db/migrate/20191017001326_create_users_security_dashboard_projects.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateUsersSecurityDashboardProjects < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+ INDEX_NAME = 'users_security_dashboard_projects_unique_index'
+
+ def change
+ create_table :users_security_dashboard_projects, id: false do |t|
+ t.references :user, null: false, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }
+ end
+
+ add_index :users_security_dashboard_projects, [:project_id, :user_id], name: INDEX_NAME, unique: true
+ end
+end
diff --git a/db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb b/db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb
new file mode 100644
index 00000000000..021bf7d9870
--- /dev/null
+++ b/db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb
@@ -0,0 +1,17 @@
+# 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 AddRemoveSourceBranchAfterMergeToProjects < ActiveRecord::Migration[5.1]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def up
+ add_column :projects, :remove_source_branch_after_merge, :boolean
+ end
+
+ def down
+ remove_column :projects, :remove_source_branch_after_merge
+ end
+end
diff --git a/db/migrate/20191017134513_add_deployment_merge_requests.rb b/db/migrate/20191017134513_add_deployment_merge_requests.rb
new file mode 100644
index 00000000000..dbe09463d22
--- /dev/null
+++ b/db/migrate/20191017134513_add_deployment_merge_requests.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class AddDeploymentMergeRequests < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :deployment_merge_requests, id: false do |t|
+ t.references(
+ :deployment,
+ foreign_key: { on_delete: :cascade },
+ type: :integer,
+ index: false,
+ null: false
+ )
+
+ t.references(
+ :merge_request,
+ foreign_key: { on_delete: :cascade },
+ type: :integer,
+ index: true,
+ null: false
+ )
+
+ t.index(
+ [:deployment_id, :merge_request_id],
+ unique: true,
+ name: 'idx_deployment_merge_requests_unique_index'
+ )
+ end
+ end
+end
diff --git a/db/migrate/20191017191341_create_clusters_applications_crossplane.rb b/db/migrate/20191017191341_create_clusters_applications_crossplane.rb
new file mode 100644
index 00000000000..8dc25c56116
--- /dev/null
+++ b/db/migrate/20191017191341_create_clusters_applications_crossplane.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateClustersApplicationsCrossplane < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :clusters_applications_crossplane do |t|
+ t.timestamps_with_timezone null: false
+ t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.integer :status, null: false
+ t.string :version, null: false, limit: 255
+ t.string :stack, null: false, limit: 255
+ t.text :status_reason
+ t.index :cluster_id, unique: true
+ end
+ end
+end
diff --git a/db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb b/db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb
new file mode 100644
index 00000000000..a3de3f34c44
--- /dev/null
+++ b/db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddMergeRequestsIndexOnTargetProjectAndBranch < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_requests, [:target_project_id, :target_branch],
+ where: "state_id = 1 AND merge_when_pipeline_succeeds = true"
+ end
+
+ def down
+ remove_concurrent_index :merge_requests, [:target_project_id, :target_branch]
+ end
+end
diff --git a/db/migrate/20191023152913_add_default_and_free_plans.rb b/db/migrate/20191023152913_add_default_and_free_plans.rb
new file mode 100644
index 00000000000..4f5f8000386
--- /dev/null
+++ b/db/migrate/20191023152913_add_default_and_free_plans.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddDefaultAndFreePlans < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ class Plan < ApplicationRecord
+ end
+
+ def up
+ plan_names.each do |plan_name|
+ Plan.create_with(title: plan_name.titleize).find_or_create_by(name: plan_name)
+ end
+ end
+
+ def down
+ Plan.where(name: plan_names).delete_all
+ end
+
+ private
+
+ def plan_names
+ [
+ ('free' if Gitlab.com?),
+ 'default'
+ ].compact
+ end
+end
diff --git a/db/migrate/20191024134020_add_index_to_zoom_meetings.rb b/db/migrate/20191024134020_add_index_to_zoom_meetings.rb
new file mode 100644
index 00000000000..ef3657b6a5e
--- /dev/null
+++ b/db/migrate/20191024134020_add_index_to_zoom_meetings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToZoomMeetings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :zoom_meetings, :issue_status
+ end
+
+ def down
+ remove_concurrent_index :zoom_meetings, :issue_status if index_exists?(:zoom_meetings, :issue_status)
+ end
+end
diff --git a/db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb b/db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb
new file mode 100644
index 00000000000..9d19279510a
--- /dev/null
+++ b/db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class SetApplicationSettingsDefaultProjectAndSnippetVisibility < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_column_null :application_settings, :default_project_visibility, false, 0
+ change_column_default :application_settings, :default_project_visibility, from: nil, to: 0
+
+ change_column_null :application_settings, :default_snippet_visibility, false, 0
+ change_column_default :application_settings, :default_snippet_visibility, from: nil, to: 0
+ end
+end
diff --git a/db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb b/db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb
new file mode 100644
index 00000000000..18a8a2306e2
--- /dev/null
+++ b/db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSetupForCompanyToUserPreferences < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :user_preferences, :setup_for_company, :boolean
+ end
+end
diff --git a/db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb b/db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb
new file mode 100644
index 00000000000..4e3b2da670e
--- /dev/null
+++ b/db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenameSnowplowSiteIdToSnowplowAppId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :application_settings, :snowplow_site_id, :snowplow_app_id
+ end
+
+ def down
+ undo_rename_column_concurrently :application_settings, :snowplow_site_id, :snowplow_app_id
+ end
+end
diff --git a/db/migrate/20191029125305_create_packages_conan_metadata.rb b/db/migrate/20191029125305_create_packages_conan_metadata.rb
new file mode 100644
index 00000000000..c6abc509e41
--- /dev/null
+++ b/db/migrate/20191029125305_create_packages_conan_metadata.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreatePackagesConanMetadata < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :packages_conan_metadata do |t|
+ t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
+ t.timestamps_with_timezone
+ t.string "package_username", null: false, limit: 255
+ t.string "package_channel", null: false, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb b/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb
new file mode 100644
index 00000000000..8db11724874
--- /dev/null
+++ b/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddEnabledToGrafanaIntegrations < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(
+ :grafana_integrations,
+ :enabled,
+ :boolean,
+ allow_null: false,
+ default: false
+ )
+ end
+
+ def down
+ remove_column(:grafana_integrations, :enabled)
+ end
+end
diff --git a/db/migrate/20191030135044_create_plan_limits.rb b/db/migrate/20191030135044_create_plan_limits.rb
new file mode 100644
index 00000000000..291d9824f6d
--- /dev/null
+++ b/db/migrate/20191030135044_create_plan_limits.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreatePlanLimits < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :plan_limits, id: false do |t|
+ t.references :plan, foreign_key: { on_delete: :cascade }, null: false, index: { unique: true }
+ t.integer :ci_active_pipelines, null: false, default: 0
+ t.integer :ci_pipeline_size, null: false, default: 0
+ t.integer :ci_active_jobs, null: false, default: 0
+ end
+ end
+end
diff --git a/db/migrate/20191030152934_move_limits_from_plans.rb b/db/migrate/20191030152934_move_limits_from_plans.rb
new file mode 100644
index 00000000000..020a028f648
--- /dev/null
+++ b/db/migrate/20191030152934_move_limits_from_plans.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class MoveLimitsFromPlans < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ execute <<~SQL
+ INSERT INTO plan_limits (plan_id, ci_active_pipelines, ci_pipeline_size, ci_active_jobs)
+ SELECT id, COALESCE(active_pipelines_limit, 0), COALESCE(pipeline_size_limit, 0), COALESCE(active_jobs_limit, 0)
+ FROM plans
+ SQL
+ end
+
+ def down
+ execute 'DELETE FROM plan_limits'
+ end
+end
diff --git a/db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb b/db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb
new file mode 100644
index 00000000000..b2baaee2b76
--- /dev/null
+++ b/db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class ReplaceIndexOnMetricsMergedAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_request_metrics, :merged_at
+ remove_concurrent_index :merge_request_metrics, [:merged_at, :id]
+ end
+
+ def down
+ add_concurrent_index :merge_request_metrics, [:merged_at, :id]
+ remove_concurrent_index :merge_request_metrics, :merged_at
+ end
+end
diff --git a/db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb b/db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb
new file mode 100644
index 00000000000..3a167b4c67f
--- /dev/null
+++ b/db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddEksCredentialsToApplicationSettings < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :eks_integration_enabled, :boolean, null: false, default: false
+ add_column :application_settings, :eks_account_id, :string, limit: 128
+ add_column :application_settings, :eks_access_key_id, :string, limit: 128
+ add_column :application_settings, :encrypted_eks_secret_access_key_iv, :string, limit: 255
+ add_column :application_settings, :encrypted_eks_secret_access_key, :text
+ end
+end
diff --git a/db/migrate/20191104205020_add_license_details_to_application_settings.rb b/db/migrate/20191104205020_add_license_details_to_application_settings.rb
new file mode 100644
index 00000000000..f951ae6492d
--- /dev/null
+++ b/db/migrate/20191104205020_add_license_details_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddLicenseDetailsToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :license_trial_ends_on, :date, null: true
+ end
+end
diff --git a/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb b/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb
new file mode 100644
index 00000000000..8fb657bf9e7
--- /dev/null
+++ b/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddReportTypeToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerabilities, :report_type, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20191105193652_add_index_on_deployments_updated_at.rb b/db/migrate/20191105193652_add_index_on_deployments_updated_at.rb
new file mode 100644
index 00000000000..10371c26dcc
--- /dev/null
+++ b/db/migrate/20191105193652_add_index_on_deployments_updated_at.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnDeploymentsUpdatedAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_COLUMNS = [:project_id, :updated_at]
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:deployments, INDEX_COLUMNS)
+ end
+
+ def down
+ remove_concurrent_index(:deployments, INDEX_COLUMNS)
+ end
+end
diff --git a/db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb b/db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb
new file mode 100644
index 00000000000..731ed82c999
--- /dev/null
+++ b/db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddSourcegraphAdminAndUserPreferences < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ add_column(:application_settings, :sourcegraph_public_only, :boolean, default: true, null: false)
+ add_column(:user_preferences, :sourcegraph_enabled, :boolean)
+ end
+
+ def down
+ remove_column(:application_settings, :sourcegraph_public_only)
+ remove_column(:user_preferences, :sourcegraph_enabled)
+ end
+end
diff --git a/db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb b/db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb
new file mode 100644
index 00000000000..06849cf9bfd
--- /dev/null
+++ b/db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToProjectsOnMarkedForDeletion < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :projects, :marked_for_deletion_at, where: 'marked_for_deletion_at IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :projects, :marked_for_deletion_at
+ end
+end
diff --git a/db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb b/db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb
new file mode 100644
index 00000000000..74ef0f27b3e
--- /dev/null
+++ b/db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddGroupIdToImportExportUploads < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :import_export_uploads, :group_id, :bigint
+ end
+end
diff --git a/db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb b/db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb
new file mode 100644
index 00000000000..403de3f33ed
--- /dev/null
+++ b/db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddGroupFkToImportExportUploads < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :import_export_uploads, :namespaces, column: :group_id, on_delete: :cascade
+ add_concurrent_index :import_export_uploads, :group_id, unique: true, where: 'group_id IS NOT NULL'
+ end
+
+ def down
+ remove_foreign_key_without_error(:import_export_uploads, column: :group_id)
+ remove_concurrent_index(:import_export_uploads, :group_id)
+ end
+end
diff --git a/db/migrate/20191111121500_default_ci_config_path.rb b/db/migrate/20191111121500_default_ci_config_path.rb
new file mode 100644
index 00000000000..f391f5ffe99
--- /dev/null
+++ b/db/migrate/20191111121500_default_ci_config_path.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class DefaultCiConfigPath < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :application_settings, :default_ci_config_path, :string, limit: 255
+ end
+
+ def down
+ remove_column :application_settings, :default_ci_config_path
+ end
+end
diff --git a/db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb b/db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb
new file mode 100644
index 00000000000..b0c513737e8
--- /dev/null
+++ b/db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddCachedMarkdownVersionToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerabilities, :cached_markdown_version, :integer
+ end
+end
diff --git a/db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb b/db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb
new file mode 100644
index 00000000000..3893c0422c7
--- /dev/null
+++ b/db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexesForProjectsApiDefaultParams < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :projects, %i(visibility_level created_at id)
+ remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level'
+ end
+
+ def down
+ add_concurrent_index :projects, :visibility_level
+ remove_concurrent_index :projects, %i(visibility_level created_at id)
+ end
+end
diff --git a/db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb b/db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb
new file mode 100644
index 00000000000..6ebc6a72854
--- /dev/null
+++ b/db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexesForProjectsApiDefaultParamsAuthenticated < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :projects, %i(created_at id)
+ remove_concurrent_index_by_name :projects, 'index_projects_on_created_at'
+ end
+
+ def down
+ add_concurrent_index :projects, :created_at
+ remove_concurrent_index_by_name :projects, 'index_projects_on_created_at_and_id'
+ end
+end
diff --git a/db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb b/db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb
new file mode 100644
index 00000000000..76cb511424e
--- /dev/null
+++ b/db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class EnsureNoEmptyMilestoneTitles < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ loop do
+ rows_updated = exec_update <<~SQL
+ UPDATE milestones SET title = '%BLANK' WHERE id IN (SELECT id FROM milestones WHERE title = '' LIMIT 500)
+ SQL
+ break if rows_updated < 500
+ end
+ end
+
+ def down; end
+end
diff --git a/db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb b/db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb
new file mode 100644
index 00000000000..ec45a729ebb
--- /dev/null
+++ b/db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddResolvedAttributesToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :vulnerabilities, :resolved_by_id, :bigint
+ add_column :vulnerabilities, :resolved_at, :datetime_with_timezone
+ end
+
+ def down
+ remove_column :vulnerabilities, :resolved_at
+ remove_column :vulnerabilities, :resolved_by_id
+ end
+end
diff --git a/db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb b/db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb
new file mode 100644
index 00000000000..e0a125ca756
--- /dev/null
+++ b/db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddForeignKeyOnResolvedByIdToVulnerabilities < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerabilities, :resolved_by_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :resolved_by_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key :vulnerabilities, column: :resolved_by_id
+ remove_concurrent_index :vulnerabilities, :resolved_by_id
+ end
+end
diff --git a/db/migrate/20191115091425_create_vulnerability_issue_links.rb b/db/migrate/20191115091425_create_vulnerability_issue_links.rb
new file mode 100644
index 00000000000..8398b6357c4
--- /dev/null
+++ b/db/migrate/20191115091425_create_vulnerability_issue_links.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityIssueLinks < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :vulnerability_issue_links do |t|
+ # index: false because idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id refers the same column
+ t.references :vulnerability, null: false, index: false, foreign_key: { on_delete: :cascade }
+ # index: true is implied
+ t.references :issue, null: false, foreign_key: { on_delete: :cascade }
+ t.integer 'link_type', limit: 2, null: false, default: 1 # 'related'
+ t.index %i[vulnerability_id issue_id],
+ name: 'idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id',
+ unique: true # only one link (and of only one type) is allowed
+ t.index %i[vulnerability_id link_type],
+ name: 'idx_vulnerability_issue_links_on_vulnerability_id_and_link_type',
+ where: 'link_type = 2',
+ unique: true # only one 'created' link per vulnerability is allowed
+ t.timestamps_with_timezone
+ end
+ end
+end