summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 12:52:10 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 12:52:10 +0000
commitdba864470fbcbb6bdd5b94eb510acdce62c962d8 (patch)
treee8ead0b84e7b814f5891d2c8cd3db2d6b635fb64 /db
parentb7d29500f28ff59c8898cdf889a40d3da908f162 (diff)
downloadgitlab-ce-dba864470fbcbb6bdd5b94eb510acdce62c962d8.tar.gz
Add latest changes from gitlab-org/gitlab@12-8-stable-ee
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/14_pipelines.rb5
-rw-r--r--db/fixtures/development/17_cycle_analytics.rb4
-rw-r--r--db/fixtures/development/26_container_images.rb65
-rw-r--r--db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb6
-rw-r--r--db/migrate/20190920224341_create_merge_request_context_commits_and_diffs.rb41
-rw-r--r--db/migrate/20190926225633_create_x509_signatures.rb41
-rw-r--r--db/migrate/20191031095636_create_project_settings.rb12
-rw-r--r--db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb26
-rw-r--r--db/migrate/20191209143606_add_deleted_at_to_description_versions.rb9
-rw-r--r--db/migrate/20191217165641_add_saml_provider_prohibited_outer_forks.rb17
-rw-r--r--db/migrate/20191218190253_add_tab_width_to_user_preferences.rb9
-rw-r--r--db/migrate/20191223124940_add_scheduling_type_to_ci_builds.rb11
-rw-r--r--db/migrate/20200109030418_add_sorting_index_to_packages.rb21
-rw-r--r--db/migrate/20200109233938_remove_project_id_index_from_packages.rb17
-rw-r--r--db/migrate/20200114140305_add_fields_to_application_settings_for_merge_requests_approvals.rb29
-rw-r--r--db/migrate/20200116051619_drop_background_migration_jobs.rb18
-rw-r--r--db/migrate/20200116175538_update_timestamp_softwarelicensespolicy.rb28
-rw-r--r--db/migrate/20200117194830_add_iid_to_operations_feature_flags.rb13
-rw-r--r--db/migrate/20200117194840_add_index_on_operations_feature_flags_iid.rb17
-rw-r--r--db/migrate/20200121132641_update_timestamp_softwarelicensespolicy_not_null.rb15
-rw-r--r--db/migrate/20200121192942_create_geo_events.rb14
-rw-r--r--db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb9
-rw-r--r--db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb20
-rw-r--r--db/migrate/20200121194154_add_geo_events_foreign_key.rb20
-rw-r--r--db/migrate/20200121200203_create_group_deploy_tokens.rb16
-rw-r--r--db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb17
-rw-r--r--db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb17
-rw-r--r--db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb17
-rw-r--r--db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb26
-rw-r--r--db/migrate/20200123091422_remove_analytics_repository_files_fk_on_other_analytics_tables.rb24
-rw-r--r--db/migrate/20200123091622_drop_analytics_repository_files_table.rb21
-rw-r--r--db/migrate/20200123091734_drop_analytics_repository_file_commits_table.rb27
-rw-r--r--db/migrate/20200123091854_drop_analytics_repository_file_edits_table.rb27
-rw-r--r--db/migrate/20200124053531_add_source_to_import_failures.rb9
-rw-r--r--db/migrate/20200124143014_add_restrict_deployment_order_to_project_ci_cd_settings.rb9
-rw-r--r--db/migrate/20200128105731_add_duration_to_merge_trains.rb10
-rw-r--r--db/migrate/20200128141125_add_index_web_hooks_on_group_id.rb17
-rw-r--r--db/migrate/20200128184209_add_usage_to_pages_domains.rb18
-rw-r--r--db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb21
-rw-r--r--db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb17
-rw-r--r--db/migrate/20200129133716_add_resource_milestone_events_table.rb25
-rw-r--r--db/migrate/20200129172428_add_index_on_audit_events_id_desc.rb24
-rw-r--r--db/migrate/20200130134335_add_cert_and_key_to_serverless_domain_cluster.rb13
-rw-r--r--db/migrate/20200130161817_drop_unneeded_indexes_for_projects_api_requests.rb31
-rw-r--r--db/migrate/20200131140428_create_index_on_auto_stop_in.rb17
-rw-r--r--db/migrate/20200131181354_add_health_status_to_epics.rb9
-rw-r--r--db/migrate/20200131191754_add_health_status_to_issues.rb9
-rw-r--r--db/migrate/20200202100932_add_service_desk_project_key.rb9
-rw-r--r--db/migrate/20200203025400_default_lock_version_to_zero_for_merge_requests.rb17
-rw-r--r--db/migrate/20200203025602_default_lock_version_to_zero_for_issues.rb17
-rw-r--r--db/migrate/20200203025619_default_lock_version_to_zero_for_epics.rb17
-rw-r--r--db/migrate/20200203025744_default_lock_version_to_zero_for_ci_builds.rb17
-rw-r--r--db/migrate/20200203025801_default_lock_version_to_zero_for_ci_stages.rb17
-rw-r--r--db/migrate/20200203025821_default_lock_version_to_zero_for_ci_pipelines.rb17
-rw-r--r--db/migrate/20200203173508_add_confirmed_attributes_to_vulnerabilities.rb10
-rw-r--r--db/migrate/20200203183508_add_index_for_vulnerability_confirmed_by.rb19
-rw-r--r--db/migrate/20200203232433_create_security_scan.rb24
-rw-r--r--db/migrate/20200204070729_add_elasticsearch_indexed_field_length_limit_to_application_settings.rb17
-rw-r--r--db/migrate/20200204131054_change_broadcast_message_index.rb19
-rw-r--r--db/migrate/20200205143231_add_dissmised_at_to_user_callouts.rb9
-rw-r--r--db/migrate/20200206112850_create_snippet_repository_table.rb13
-rw-r--r--db/migrate/20200207090921_add_nuget_index_to_packages_packages.rb18
-rw-r--r--db/migrate/20200207132752_add_es_bulk_config.rb11
-rw-r--r--db/migrate/20200207151640_create_deployment_clusters.rb16
-rw-r--r--db/migrate/20200207182131_replace_conan_metadata_index.rb25
-rw-r--r--db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb9
-rw-r--r--db/migrate/20200210135504_remove_packages_deprecated_dependencies.rb13
-rw-r--r--db/migrate/20200210184410_create_operations_strategies_table.rb13
-rw-r--r--db/migrate/20200210184420_create_operations_scopes_table.rb14
-rw-r--r--db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb36
-rw-r--r--db/post_migrate/20191115115522_migrate_epic_notes_mentions_to_db.rb45
-rw-r--r--db/post_migrate/20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb2
-rw-r--r--db/post_migrate/20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb56
-rw-r--r--db/post_migrate/20200114113341_patch_prometheus_services_for_shared_cluster_applications.rb79
-rw-r--r--db/post_migrate/20200117194850_backfill_operations_feature_flags_iid.rb24
-rw-r--r--db/post_migrate/20200117194900_delete_internal_ids_where_feature_flags_usage.rb19
-rw-r--r--db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb30
-rw-r--r--db/post_migrate/20200122123016_backfill_project_settings.rb29
-rw-r--r--db/post_migrate/20200122144759_drop_kibana_column.rb9
-rw-r--r--db/post_migrate/20200127111840_fix_projects_without_project_feature.rb22
-rw-r--r--db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb17
-rw-r--r--db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb44
-rw-r--r--db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.rb22
-rw-r--r--db/post_migrate/20200206091544_migrate_create_commit_signature_worker_sidekiq_queue.rb15
-rw-r--r--db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb33
-rw-r--r--db/post_migrate/20200207184023_add_temporary_index_to_promotion_notes.rb23
-rw-r--r--db/post_migrate/20200207185149_schedule_fix_orphan_promoted_issues.rb35
-rw-r--r--db/post_migrate/20200210062432_schedule_link_lfs_objects.rb17
-rw-r--r--db/post_migrate/20200210092405_save_instance_administrators_group_id.rb42
-rw-r--r--db/post_migrate/20200211152410_remove_instance_from_services.rb19
-rw-r--r--db/post_migrate/20200212052620_readd_template_column_to_services.rb23
-rw-r--r--db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb30
-rw-r--r--db/post_migrate/20200213220159_migrate_store_security_reports_sidekiq_queue.rb15
-rw-r--r--db/post_migrate/20200213220211_migrate_sync_security_reports_to_report_approval_rules_sidekiq_queue.rb17
-rw-r--r--db/schema.rb306
95 files changed, 2073 insertions, 165 deletions
diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb
index 417a68d6ad7..7a9b97dfefa 100644
--- a/db/fixtures/development/14_pipelines.rb
+++ b/db/fixtures/development/14_pipelines.rb
@@ -165,9 +165,10 @@ class Gitlab::Seeder::Pipelines
end
def job_attributes(pipeline, opts)
- { name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]),
+ {
+ name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]),
ref: pipeline.ref, tag: false, user: build_user, project: @project, pipeline: pipeline,
- created_at: Time.now, updated_at: Time.now
+ scheduling_type: :stage, created_at: Time.now, updated_at: Time.now
}.merge(opts)
end
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb
index b2252d31cac..2bf3c918006 100644
--- a/db/fixtures/development/17_cycle_analytics.rb
+++ b/db/fixtures/development/17_cycle_analytics.rb
@@ -109,7 +109,7 @@ class Gitlab::Seeder::CycleAnalytics
def create_issues
Array.new(@issue_count) do
issue_params = {
- title: "Cycle Analytics: #{FFaker::Lorem.sentence(6)}",
+ title: "Value Stream Analytics: #{FFaker::Lorem.sentence(6)}",
description: FFaker::Lorem.sentence,
state: 'opened',
assignees: [@project.team.users.sample]
@@ -166,7 +166,7 @@ class Gitlab::Seeder::CycleAnalytics
Timecop.travel 12.hours.from_now
opts = {
- title: 'Cycle Analytics merge_request',
+ title: 'Value Stream Analytics merge_request',
description: "Fixes #{issue.to_reference}",
source_branch: branch,
target_branch: 'master'
diff --git a/db/fixtures/development/26_container_images.rb b/db/fixtures/development/26_container_images.rb
new file mode 100644
index 00000000000..5b5879673b9
--- /dev/null
+++ b/db/fixtures/development/26_container_images.rb
@@ -0,0 +1,65 @@
+# frozen_string_literal: true
+
+class Gitlab::Seeder::ContainerImages
+ attr_reader :tmp_dir, :project, :images_count
+
+ DOCKER_FILE_CONTENTS = <<~EOS
+ FROM scratch
+ ARG tag
+ ENV tag=$tag
+ EOS
+
+ def initialize(project, images_count)
+ @project = project
+ @images_count = images_count
+ initialize_tmp_dir
+ end
+
+ def seed!
+ images_count.times do |i|
+ image_path = "#{project.container_registry_url}:tag_#{i}"
+ build_image(image_path)
+ push_image(image_path)
+ puts '.'
+ end
+ ensure
+ FileUtils.remove_entry tmp_dir
+ end
+
+ private
+
+ def build_image(image_path)
+ system(*%W[docker build -t #{image_path} --build-arg tag=gitlab_container_image_seed .], chdir: @tmp_dir)
+ end
+
+ def push_image(image_path)
+ system(*%W[docker push #{image_path}], chdir: @tmp_dir)
+ end
+
+ def initialize_tmp_dir
+ @tmp_dir = Dir.mktmpdir('gitlab_seeder_container_images')
+
+ File.write(File.join(@tmp_dir, 'Dockerfile'), DOCKER_FILE_CONTENTS)
+ end
+end
+
+Gitlab::Seeder.quiet do
+ flag = 'SEED_CONTAINER_IMAGES'
+
+ if ENV[flag]
+ admin_user = User.admins.first
+ images_count = Integer(ENV[flag])
+
+ Project.not_mass_generated.visible_to_user(admin_user).sample(1).each do |project|
+ puts "\nSeeding #{images_count} container images to the '#{project.full_path}' project."
+
+ seeder = Gitlab::Seeder::ContainerImages.new(project, images_count)
+ seeder.seed!
+ rescue => e
+ puts "\nSeeding container images failed with #{e.message}."
+ puts "Make sure that the registry is running (https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/howto/registry.md) and that Docker CLI (https://www.docker.com/products/docker-desktop) is installed."
+ end
+ else
+ puts "Skipped. Use the `#{flag}` environment variable to seed container images to the registry."
+ end
+end
diff --git a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb
index e6427534310..55ef3c79f3f 100644
--- a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb
+++ b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb
@@ -7,9 +7,13 @@ class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1]
disable_ddl_transaction!
+ # rubocop:disable Migration/UpdateLargeTable
+ # rubocop:disable Migration/AddColumnWithDefault
def up
- add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
+ add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false
end
+ # rubocop:enable Migration/UpdateLargeTable
+ # rubocop:enable Migration/AddColumnWithDefault
def down
remove_column :project_ci_cd_settings, :merge_trains_enabled
diff --git a/db/migrate/20190920224341_create_merge_request_context_commits_and_diffs.rb b/db/migrate/20190920224341_create_merge_request_context_commits_and_diffs.rb
new file mode 100644
index 00000000000..dcc9da670f7
--- /dev/null
+++ b/db/migrate/20190920224341_create_merge_request_context_commits_and_diffs.rb
@@ -0,0 +1,41 @@
+# 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 CreateMergeRequestContextCommitsAndDiffs < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :merge_request_context_commits do |t|
+ t.references :merge_request, foreign_key: { on_delete: :cascade }
+ t.datetime_with_timezone :authored_date
+ t.datetime_with_timezone :committed_date
+ t.binary :sha, null: false
+ t.integer :relative_order, null: false
+ t.text :author_name
+ t.text :author_email
+ t.text :committer_name
+ t.text :committer_email
+ t.text :message
+ t.index [:merge_request_id, :sha], unique: true, name: 'index_mr_context_commits_on_merge_request_id_and_sha'
+ end
+
+ create_table :merge_request_context_commit_diff_files, id: false do |t|
+ t.references :merge_request_context_commit, foreign_key: { on_delete: :cascade }, index: { name: "idx_mr_cc_diff_files_on_mr_cc_id" }
+ t.binary :sha, null: false
+ t.integer :relative_order, null: false
+ t.string :a_mode, null: false, limit: 255
+ t.string :b_mode, null: false, limit: 255
+ t.boolean :new_file, null: false
+ t.boolean :renamed_file, null: false
+ t.boolean :deleted_file, null: false
+ t.boolean :too_large, null: false
+ t.boolean :binary
+ t.text :new_path, null: false
+ t.text :old_path, null: false
+ t.text :diff
+ t.index [:merge_request_context_commit_id, :sha], name: 'idx_mr_cc_diff_files_on_mr_cc_id_and_sha'
+ end
+ end
+end
diff --git a/db/migrate/20190926225633_create_x509_signatures.rb b/db/migrate/20190926225633_create_x509_signatures.rb
new file mode 100644
index 00000000000..88f6b03afba
--- /dev/null
+++ b/db/migrate/20190926225633_create_x509_signatures.rb
@@ -0,0 +1,41 @@
+# 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 CreateX509Signatures < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :x509_issuers do |t|
+ t.timestamps_with_timezone null: false
+
+ t.string :subject_key_identifier, index: true, null: false, unique: true, limit: 255
+ t.string :subject, null: false, limit: 255
+ t.string :crl_url, null: false, limit: 255
+ end
+
+ create_table :x509_certificates do |t|
+ t.timestamps_with_timezone null: false
+
+ t.string :subject_key_identifier, index: true, null: false, unique: true, limit: 255
+ t.string :subject, null: false, limit: 255
+ t.string :email, null: false, limit: 255
+ t.binary :serial_number, null: false
+
+ t.integer :certificate_status, limit: 2, default: 0, null: false
+
+ t.references :x509_issuer, index: true, null: false, foreign_key: { on_delete: :cascade }
+ end
+
+ create_table :x509_commit_signatures do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :project, index: true, null: false, foreign_key: { on_delete: :cascade }
+ t.references :x509_certificate, index: true, null: false, foreign_key: { on_delete: :cascade }
+
+ t.binary :commit_sha, index: true, null: false
+ t.integer :verification_status, limit: 2, default: 0, null: false
+ end
+ end
+end
diff --git a/db/migrate/20191031095636_create_project_settings.rb b/db/migrate/20191031095636_create_project_settings.rb
new file mode 100644
index 00000000000..0263eceb3c1
--- /dev/null
+++ b/db/migrate/20191031095636_create_project_settings.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreateProjectSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :project_settings, id: false do |t|
+ t.timestamps_with_timezone null: false
+ t.references :project, primary_key: true, default: nil, type: :integer, index: false, foreign_key: { on_delete: :cascade }
+ end
+ end
+end
diff --git a/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb b/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb
new file mode 100644
index 00000000000..12e22b4744c
--- /dev/null
+++ b/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault
+ :oauth_applications,
+ :confidential,
+ :boolean,
+ default: false, # assume all existing applications are non-confidential
+ allow_null: false
+ )
+
+ # set the default to true so that all future applications are confidential by default
+ change_column_default(:oauth_applications, :confidential, true)
+ end
+
+ def down
+ remove_column :oauth_applications, :confidential
+ end
+end
diff --git a/db/migrate/20191209143606_add_deleted_at_to_description_versions.rb b/db/migrate/20191209143606_add_deleted_at_to_description_versions.rb
new file mode 100644
index 00000000000..02a3d1271c2
--- /dev/null
+++ b/db/migrate/20191209143606_add_deleted_at_to_description_versions.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDeletedAtToDescriptionVersions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :description_versions, :deleted_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20191217165641_add_saml_provider_prohibited_outer_forks.rb b/db/migrate/20191217165641_add_saml_provider_prohibited_outer_forks.rb
new file mode 100644
index 00000000000..6cd32cdcfe9
--- /dev/null
+++ b/db/migrate/20191217165641_add_saml_provider_prohibited_outer_forks.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddSamlProviderProhibitedOuterForks < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :saml_providers, :prohibited_outer_forks, :boolean, default: false, allow_null: true
+ end
+
+ def down
+ remove_column :saml_providers, :prohibited_outer_forks
+ end
+end
diff --git a/db/migrate/20191218190253_add_tab_width_to_user_preferences.rb b/db/migrate/20191218190253_add_tab_width_to_user_preferences.rb
new file mode 100644
index 00000000000..b03dd8f76b9
--- /dev/null
+++ b/db/migrate/20191218190253_add_tab_width_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddTabWidthToUserPreferences < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column(:user_preferences, :tab_width, :integer, limit: 2)
+ end
+end
diff --git a/db/migrate/20191223124940_add_scheduling_type_to_ci_builds.rb b/db/migrate/20191223124940_add_scheduling_type_to_ci_builds.rb
new file mode 100644
index 00000000000..0cb42cdc328
--- /dev/null
+++ b/db/migrate/20191223124940_add_scheduling_type_to_ci_builds.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddSchedulingTypeToCiBuilds < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :ci_builds, :scheduling_type, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20200109030418_add_sorting_index_to_packages.rb b/db/migrate/20200109030418_add_sorting_index_to_packages.rb
new file mode 100644
index 00000000000..989f3de3c04
--- /dev/null
+++ b/db/migrate/20200109030418_add_sorting_index_to_packages.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddSortingIndexToPackages < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :packages_packages, [:project_id, :created_at]
+ add_concurrent_index :packages_packages, [:project_id, :version]
+ add_concurrent_index :packages_packages, [:project_id, :package_type]
+ end
+
+ def down
+ remove_concurrent_index :packages_packages, [:project_id, :created_at]
+ remove_concurrent_index :packages_packages, [:project_id, :version]
+ remove_concurrent_index :packages_packages, [:project_id, :package_type]
+ end
+end
diff --git a/db/migrate/20200109233938_remove_project_id_index_from_packages.rb b/db/migrate/20200109233938_remove_project_id_index_from_packages.rb
new file mode 100644
index 00000000000..e806c5d5a18
--- /dev/null
+++ b/db/migrate/20200109233938_remove_project_id_index_from_packages.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RemoveProjectIdIndexFromPackages < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index :packages_packages, [:project_id]
+ end
+
+ def down
+ add_concurrent_index :packages_packages, [:project_id]
+ end
+end
diff --git a/db/migrate/20200114140305_add_fields_to_application_settings_for_merge_requests_approvals.rb b/db/migrate/20200114140305_add_fields_to_application_settings_for_merge_requests_approvals.rb
new file mode 100644
index 00000000000..5e035f91f24
--- /dev/null
+++ b/db/migrate/20200114140305_add_fields_to_application_settings_for_merge_requests_approvals.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddFieldsToApplicationSettingsForMergeRequestsApprovals < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column(:application_settings,
+ :disable_overriding_approvers_per_merge_request,
+ :boolean,
+ default: false,
+ null: false)
+ add_column(:application_settings,
+ :prevent_merge_requests_author_approval,
+ :boolean,
+ default: false,
+ null: false)
+ add_column(:application_settings,
+ :prevent_merge_requests_committers_approval,
+ :boolean,
+ default: false,
+ null: false)
+ end
+
+ def down
+ remove_column(:application_settings, :disable_overriding_approvers_per_merge_request)
+ remove_column(:application_settings, :prevent_merge_requests_author_approval)
+ remove_column(:application_settings, :prevent_merge_requests_committers_approval)
+ end
+end
diff --git a/db/migrate/20200116051619_drop_background_migration_jobs.rb b/db/migrate/20200116051619_drop_background_migration_jobs.rb
new file mode 100644
index 00000000000..f492ec0af9d
--- /dev/null
+++ b/db/migrate/20200116051619_drop_background_migration_jobs.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class DropBackgroundMigrationJobs < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ DROPPED_JOB_CLASS = 'ActivatePrometheusServicesForSharedClusterApplications'
+ QUEUE = 'background_migration'
+
+ def up
+ Sidekiq::Queue.new(QUEUE).each do |job|
+ klass, project_id, *should_be_empty = job.args
+ next unless klass == DROPPED_JOB_CLASS && project_id.is_a?(Integer) && should_be_empty.empty?
+
+ job.delete
+ end
+ end
+end
diff --git a/db/migrate/20200116175538_update_timestamp_softwarelicensespolicy.rb b/db/migrate/20200116175538_update_timestamp_softwarelicensespolicy.rb
new file mode 100644
index 00000000000..5ed797e33a3
--- /dev/null
+++ b/db/migrate/20200116175538_update_timestamp_softwarelicensespolicy.rb
@@ -0,0 +1,28 @@
+# 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 UpdateTimestampSoftwarelicensespolicy < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ time = Time.zone.now
+
+ update_column_in_batches(:software_license_policies, :created_at, time) do |table, query|
+ query.where(table[:created_at].eq(nil))
+ end
+
+ update_column_in_batches(:software_license_policies, :updated_at, time) do |table, query|
+ query.where(table[:updated_at].eq(nil))
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20200117194830_add_iid_to_operations_feature_flags.rb b/db/migrate/20200117194830_add_iid_to_operations_feature_flags.rb
new file mode 100644
index 00000000000..b18d9788b9f
--- /dev/null
+++ b/db/migrate/20200117194830_add_iid_to_operations_feature_flags.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddIidToOperationsFeatureFlags < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :operations_feature_flags, :iid, :integer
+ end
+
+ def down
+ remove_column :operations_feature_flags, :iid
+ end
+end
diff --git a/db/migrate/20200117194840_add_index_on_operations_feature_flags_iid.rb b/db/migrate/20200117194840_add_index_on_operations_feature_flags_iid.rb
new file mode 100644
index 00000000000..67dedb56ec1
--- /dev/null
+++ b/db/migrate/20200117194840_add_index_on_operations_feature_flags_iid.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexOnOperationsFeatureFlagsIid < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :operations_feature_flags, [:project_id, :iid], unique: true
+ end
+
+ def down
+ remove_concurrent_index :operations_feature_flags, [:project_id, :iid]
+ end
+end
diff --git a/db/migrate/20200121132641_update_timestamp_softwarelicensespolicy_not_null.rb b/db/migrate/20200121132641_update_timestamp_softwarelicensespolicy_not_null.rb
new file mode 100644
index 00000000000..1da96b470ef
--- /dev/null
+++ b/db/migrate/20200121132641_update_timestamp_softwarelicensespolicy_not_null.rb
@@ -0,0 +1,15 @@
+# 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 UpdateTimestampSoftwarelicensespolicyNotNull < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_column_null(:software_license_policies, :created_at, false)
+ change_column_null(:software_license_policies, :updated_at, false)
+ end
+end
diff --git a/db/migrate/20200121192942_create_geo_events.rb b/db/migrate/20200121192942_create_geo_events.rb
new file mode 100644
index 00000000000..6dbe131051f
--- /dev/null
+++ b/db/migrate/20200121192942_create_geo_events.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateGeoEvents < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :geo_events do |t|
+ t.string :replicable_name, limit: 255, null: false
+ t.string :event_name, limit: 255, null: false
+ t.jsonb :payload, default: {}, null: false
+ t.datetime_with_timezone :created_at, null: false
+ end
+ end
+end
diff --git a/db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb b/db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb
new file mode 100644
index 00000000000..720995164b2
--- /dev/null
+++ b/db/migrate/20200121194000_add_geo_event_id_to_geo_event_log.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddGeoEventIdToGeoEventLog < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :geo_event_log, :geo_event_id, :integer
+ end
+end
diff --git a/db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb b/db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb
new file mode 100644
index 00000000000..9b0ec12c959
--- /dev/null
+++ b/db/migrate/20200121194048_add_geo_event_id_index_to_geo_event_log.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddGeoEventIdIndexToGeoEventLog < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :geo_event_log, :geo_event_id,
+ where: "(geo_event_id IS NOT NULL)",
+ using: :btree,
+ name: 'index_geo_event_log_on_geo_event_id'
+ end
+
+ def down
+ remove_concurrent_index :geo_event_log, :geo_event_id, name: 'index_geo_event_log_on_geo_event_id'
+ end
+end
diff --git a/db/migrate/20200121194154_add_geo_events_foreign_key.rb b/db/migrate/20200121194154_add_geo_events_foreign_key.rb
new file mode 100644
index 00000000000..b5e16e22989
--- /dev/null
+++ b/db/migrate/20200121194154_add_geo_events_foreign_key.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddGeoEventsForeignKey < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :geo_event_log, :geo_events,
+ column: :geo_event_id,
+ name: 'fk_geo_event_log_on_geo_event_id',
+ on_delete: :cascade
+ end
+
+ def down
+ remove_foreign_key_without_error :geo_event_log, column: :geo_event_id, name: 'fk_geo_event_log_on_geo_event_id'
+ end
+end
diff --git a/db/migrate/20200121200203_create_group_deploy_tokens.rb b/db/migrate/20200121200203_create_group_deploy_tokens.rb
new file mode 100644
index 00000000000..55b30745fcf
--- /dev/null
+++ b/db/migrate/20200121200203_create_group_deploy_tokens.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateGroupDeployTokens < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :group_deploy_tokens do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
+ t.references :deploy_token, null: false, foreign_key: { on_delete: :cascade }
+
+ t.index [:group_id, :deploy_token_id], unique: true, name: 'index_group_deploy_tokens_on_group_and_deploy_token_ids'
+ end
+ end
+end
diff --git a/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb b/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb
new file mode 100644
index 00000000000..e0cf18caf9c
--- /dev/null
+++ b/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddDeployTokenTypeToDeployTokens < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ add_column_with_default :deploy_tokens, :deploy_token_type, :integer, default: 2, limit: 2, allow_null: false # rubocop: disable Migration/AddColumnWithDefault
+ end
+
+ def down
+ remove_column :deploy_tokens, :deploy_token_type
+ end
+end
diff --git a/db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb b/db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb
new file mode 100644
index 00000000000..36ccfa4743e
--- /dev/null
+++ b/db/migrate/20200123040535_add_multi_column_index_on_lfs_objects_projects.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddMultiColumnIndexOnLfsObjectsProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :lfs_objects_projects, [:project_id, :lfs_object_id]
+ end
+
+ def down
+ remove_concurrent_index :lfs_objects_projects, [:project_id, :lfs_object_id]
+ end
+end
diff --git a/db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb b/db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb
new file mode 100644
index 00000000000..540383e8808
--- /dev/null
+++ b/db/migrate/20200123045415_remove_project_id_index_on_lfs_objects_projects.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RemoveProjectIdIndexOnLfsObjectsProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index :lfs_objects_projects, :project_id
+ end
+
+ def down
+ add_concurrent_index :lfs_objects_projects, :project_id
+ end
+end
diff --git a/db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb b/db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb
new file mode 100644
index 00000000000..94fafe214c2
--- /dev/null
+++ b/db/migrate/20200123090839_remove_analytics_repository_table_fks_on_projects.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class RemoveAnalyticsRepositoryTableFksOnProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ # Requires ExclusiveLock on all tables. analytics_* tables are empty
+ remove_foreign_key :analytics_repository_files, :projects
+ remove_foreign_key :analytics_repository_file_edits, :projects if table_exists?(:analytics_repository_file_edits) # this table might be already dropped on development environment
+ remove_foreign_key :analytics_repository_file_commits, :projects
+ end
+ end
+
+ def down
+ with_lock_retries do
+ # rubocop:disable Migration/AddConcurrentForeignKey
+ add_foreign_key :analytics_repository_files, :projects, on_delete: :cascade
+ add_foreign_key :analytics_repository_file_edits, :projects, on_delete: :cascade
+ add_foreign_key :analytics_repository_file_commits, :projects, on_delete: :cascade
+ # rubocop:enable Migration/AddConcurrentForeignKey
+ end
+ end
+end
diff --git a/db/migrate/20200123091422_remove_analytics_repository_files_fk_on_other_analytics_tables.rb b/db/migrate/20200123091422_remove_analytics_repository_files_fk_on_other_analytics_tables.rb
new file mode 100644
index 00000000000..e3e415dd0ad
--- /dev/null
+++ b/db/migrate/20200123091422_remove_analytics_repository_files_fk_on_other_analytics_tables.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class RemoveAnalyticsRepositoryFilesFkOnOtherAnalyticsTables < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ # Requires ExclusiveLock on all tables. analytics_* tables are empty
+ remove_foreign_key :analytics_repository_file_edits, :analytics_repository_files if table_exists?(:analytics_repository_file_edits) # this table might be already dropped on development environment
+ remove_foreign_key :analytics_repository_file_commits, :analytics_repository_files
+ end
+ end
+
+ def down
+ with_lock_retries do
+ # rubocop:disable Migration/AddConcurrentForeignKey
+ add_foreign_key :analytics_repository_file_edits, :analytics_repository_files, on_delete: :cascade
+ add_foreign_key :analytics_repository_file_commits, :analytics_repository_files, on_delete: :cascade
+ # rubocop:enable Migration/AddConcurrentForeignKey
+ end
+ end
+end
diff --git a/db/migrate/20200123091622_drop_analytics_repository_files_table.rb b/db/migrate/20200123091622_drop_analytics_repository_files_table.rb
new file mode 100644
index 00000000000..aa31d23920a
--- /dev/null
+++ b/db/migrate/20200123091622_drop_analytics_repository_files_table.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class DropAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ # Requires ExclusiveLock on the table. Not in use, no records, no FKs.
+ drop_table :analytics_repository_files
+ end
+
+ def down
+ create_table :analytics_repository_files do |t|
+ t.bigint :project_id, 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/20200123091734_drop_analytics_repository_file_commits_table.rb b/db/migrate/20200123091734_drop_analytics_repository_file_commits_table.rb
new file mode 100644
index 00000000000..2d3c1c9a817
--- /dev/null
+++ b/db/migrate/20200123091734_drop_analytics_repository_file_commits_table.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class DropAnalyticsRepositoryFileCommitsTable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ # Requires ExclusiveLock on the table. Not in use, no records, no FKs.
+ drop_table :analytics_repository_file_commits
+ end
+
+ def down
+ create_table :analytics_repository_file_commits do |t|
+ t.bigint :analytics_repository_file_id, null: false
+ t.index :analytics_repository_file_id, name: 'index_analytics_repository_file_commits_file_id'
+ t.bigint :project_id, 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/20200123091854_drop_analytics_repository_file_edits_table.rb b/db/migrate/20200123091854_drop_analytics_repository_file_edits_table.rb
new file mode 100644
index 00000000000..59bf2dbdca3
--- /dev/null
+++ b/db/migrate/20200123091854_drop_analytics_repository_file_edits_table.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class DropAnalyticsRepositoryFileEditsTable < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ # Requires ExclusiveLock on the table. Not in use, no records, no FKs.
+ drop_table :analytics_repository_file_edits if table_exists?(:analytics_repository_file_edits) # this table might be already dropped on development environment
+ end
+
+ def down
+ create_table :analytics_repository_file_edits do |t|
+ t.bigint :project_id, null: false
+ t.index :project_id
+ t.bigint :analytics_repository_file_id, 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/20200124053531_add_source_to_import_failures.rb b/db/migrate/20200124053531_add_source_to_import_failures.rb
new file mode 100644
index 00000000000..532d5803c74
--- /dev/null
+++ b/db/migrate/20200124053531_add_source_to_import_failures.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSourceToImportFailures < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :import_failures, :source, :string, limit: 128
+ end
+end
diff --git a/db/migrate/20200124143014_add_restrict_deployment_order_to_project_ci_cd_settings.rb b/db/migrate/20200124143014_add_restrict_deployment_order_to_project_ci_cd_settings.rb
new file mode 100644
index 00000000000..6a222ce8d51
--- /dev/null
+++ b/db/migrate/20200124143014_add_restrict_deployment_order_to_project_ci_cd_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddRestrictDeploymentOrderToProjectCiCdSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :project_ci_cd_settings, :forward_deployment_enabled, :boolean
+ end
+end
diff --git a/db/migrate/20200128105731_add_duration_to_merge_trains.rb b/db/migrate/20200128105731_add_duration_to_merge_trains.rb
new file mode 100644
index 00000000000..a7aacaba5e1
--- /dev/null
+++ b/db/migrate/20200128105731_add_duration_to_merge_trains.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddDurationToMergeTrains < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :merge_trains, :merged_at, :datetime_with_timezone
+ add_column :merge_trains, :duration, :integer
+ end
+end
diff --git a/db/migrate/20200128141125_add_index_web_hooks_on_group_id.rb b/db/migrate/20200128141125_add_index_web_hooks_on_group_id.rb
new file mode 100644
index 00000000000..8c7f6426587
--- /dev/null
+++ b/db/migrate/20200128141125_add_index_web_hooks_on_group_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexWebHooksOnGroupId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :web_hooks, :group_id, where: "type = 'GroupHook'"
+ end
+
+ def down
+ remove_concurrent_index :web_hooks, :group_id, where: "type = 'GroupHook'"
+ end
+end
diff --git a/db/migrate/20200128184209_add_usage_to_pages_domains.rb b/db/migrate/20200128184209_add_usage_to_pages_domains.rb
new file mode 100644
index 00000000000..292490078cd
--- /dev/null
+++ b/db/migrate/20200128184209_add_usage_to_pages_domains.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddUsageToPagesDomains < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ PAGES_USAGE = 0
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :pages_domains, :usage, :integer, limit: 2, default: PAGES_USAGE, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
+ end
+
+ def down
+ remove_column :pages_domains, :usage
+ end
+end
diff --git a/db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb b/db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb
new file mode 100644
index 00000000000..2f13567c540
--- /dev/null
+++ b/db/migrate/20200129034515_update_indexes_of_pages_domains_add_usage_domain_wildcard_remove_domain.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class UpdateIndexesOfPagesDomainsAddUsageDomainWildcardRemoveDomain < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :pages_domains, :usage
+ add_concurrent_index :pages_domains, [:domain, :wildcard], unique: true
+ remove_concurrent_index :pages_domains, :domain
+ end
+
+ def down
+ remove_concurrent_index :pages_domains, :usage
+ remove_concurrent_index :pages_domains, [:domain, :wildcard]
+ add_concurrent_index :pages_domains, :domain, unique: true
+ end
+end
diff --git a/db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb b/db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb
new file mode 100644
index 00000000000..74d9827e370
--- /dev/null
+++ b/db/migrate/20200129035446_rename_pages_domains_domain_type_to_scope.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenamePagesDomainsDomainTypeToScope < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :pages_domains, :domain_type, :scope
+ end
+
+ def down
+ undo_rename_column_concurrently :pages_domains, :domain_type, :scope
+ end
+end
diff --git a/db/migrate/20200129133716_add_resource_milestone_events_table.rb b/db/migrate/20200129133716_add_resource_milestone_events_table.rb
new file mode 100644
index 00000000000..0ead21820c2
--- /dev/null
+++ b/db/migrate/20200129133716_add_resource_milestone_events_table.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :resource_milestone_events, id: :bigserial do |t|
+ t.references :user, null: false, foreign_key: { on_delete: :nullify },
+ index: { name: 'index_resource_milestone_events_on_user_id' }
+ t.references :issue, null: true, foreign_key: { on_delete: :cascade },
+ index: { name: 'index_resource_milestone_events_on_issue_id' }
+ t.references :merge_request, null: true, foreign_key: { on_delete: :cascade },
+ index: { name: 'index_resource_milestone_events_on_merge_request_id' }
+ t.references :milestone, foreign_key: { on_delete: :cascade },
+ index: { name: 'index_resource_milestone_events_on_milestone_id' }
+
+ t.integer :action, limit: 2, null: false
+ t.integer :state, limit: 2, null: false
+ t.integer :cached_markdown_version
+ t.text :reference
+ t.text :reference_html
+ t.datetime_with_timezone :created_at, null: false
+ end
+ end
+end
diff --git a/db/migrate/20200129172428_add_index_on_audit_events_id_desc.rb b/db/migrate/20200129172428_add_index_on_audit_events_id_desc.rb
new file mode 100644
index 00000000000..b9182c99ebf
--- /dev/null
+++ b/db/migrate/20200129172428_add_index_on_audit_events_id_desc.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AddIndexOnAuditEventsIdDesc < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ OLD_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type'
+ NEW_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type_and_id_desc'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :audit_events, [:entity_id, :entity_type, :id], name: NEW_INDEX_NAME,
+ order: { entity_id: :asc, entity_type: :asc, id: :desc }
+
+ remove_concurrent_index_by_name :audit_events, OLD_INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :audit_events, [:entity_id, :entity_type], name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name :audit_events, NEW_INDEX_NAME
+ end
+end
diff --git a/db/migrate/20200130134335_add_cert_and_key_to_serverless_domain_cluster.rb b/db/migrate/20200130134335_add_cert_and_key_to_serverless_domain_cluster.rb
new file mode 100644
index 00000000000..39249053ee0
--- /dev/null
+++ b/db/migrate/20200130134335_add_cert_and_key_to_serverless_domain_cluster.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddCertAndKeyToServerlessDomainCluster < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :serverless_domain_cluster, :encrypted_key, :text
+ add_column :serverless_domain_cluster, :encrypted_key_iv, :string, limit: 255
+ add_column :serverless_domain_cluster, :certificate, :text
+ end
+end
diff --git a/db/migrate/20200130161817_drop_unneeded_indexes_for_projects_api_requests.rb b/db/migrate/20200130161817_drop_unneeded_indexes_for_projects_api_requests.rb
new file mode 100644
index 00000000000..50b98ab9dba
--- /dev/null
+++ b/db/migrate/20200130161817_drop_unneeded_indexes_for_projects_api_requests.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class DropUnneededIndexesForProjectsApiRequests < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ indexes = %w(
+ index_projects_api_vis20_created_at_id_desc
+ index_projects_api_vis20_last_activity_at_id_desc
+ index_projects_api_vis20_updated_at_id_desc
+ index_projects_api_vis20_name_id_desc
+ index_projects_api_vis20_path_id_desc
+ )
+
+ indexes.each do |index|
+ remove_concurrent_index_by_name :projects, index
+ end
+ end
+
+ def down
+ columns = %i(created_at last_activity_at updated_at name path)
+
+ columns.each do |column|
+ add_concurrent_index :projects, [column, :id], where: 'visibility_level = 20', order: { id: :desc }, name: "index_projects_api_vis20_#{column}_id_desc"
+ end
+ end
+end
diff --git a/db/migrate/20200131140428_create_index_on_auto_stop_in.rb b/db/migrate/20200131140428_create_index_on_auto_stop_in.rb
new file mode 100644
index 00000000000..526e7dcfe30
--- /dev/null
+++ b/db/migrate/20200131140428_create_index_on_auto_stop_in.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateIndexOnAutoStopIn < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :environments, %i[state auto_stop_at], where: "auto_stop_at IS NOT NULL AND state = 'available'"
+ end
+
+ def down
+ remove_concurrent_index :environments, %i[state auto_stop_at]
+ end
+end
diff --git a/db/migrate/20200131181354_add_health_status_to_epics.rb b/db/migrate/20200131181354_add_health_status_to_epics.rb
new file mode 100644
index 00000000000..4e5f9ab138d
--- /dev/null
+++ b/db/migrate/20200131181354_add_health_status_to_epics.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddHealthStatusToEpics < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :epics, :health_status, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20200131191754_add_health_status_to_issues.rb b/db/migrate/20200131191754_add_health_status_to_issues.rb
new file mode 100644
index 00000000000..ca4e797f4b7
--- /dev/null
+++ b/db/migrate/20200131191754_add_health_status_to_issues.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddHealthStatusToIssues < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :issues, :health_status, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20200202100932_add_service_desk_project_key.rb b/db/migrate/20200202100932_add_service_desk_project_key.rb
new file mode 100644
index 00000000000..d42ed4159e4
--- /dev/null
+++ b/db/migrate/20200202100932_add_service_desk_project_key.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddServiceDeskProjectKey < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :service_desk_settings, :project_key, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20200203025400_default_lock_version_to_zero_for_merge_requests.rb b/db/migrate/20200203025400_default_lock_version_to_zero_for_merge_requests.rb
new file mode 100644
index 00000000000..c0c58cfa3a7
--- /dev/null
+++ b/db/migrate/20200203025400_default_lock_version_to_zero_for_merge_requests.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 DefaultLockVersionToZeroForMergeRequests < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ change_column_default :merge_requests, :lock_version, from: nil, to: 0
+ end
+ end
+end
diff --git a/db/migrate/20200203025602_default_lock_version_to_zero_for_issues.rb b/db/migrate/20200203025602_default_lock_version_to_zero_for_issues.rb
new file mode 100644
index 00000000000..72c265fdf38
--- /dev/null
+++ b/db/migrate/20200203025602_default_lock_version_to_zero_for_issues.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 DefaultLockVersionToZeroForIssues < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ change_column_default :issues, :lock_version, from: nil, to: 0
+ end
+ end
+end
diff --git a/db/migrate/20200203025619_default_lock_version_to_zero_for_epics.rb b/db/migrate/20200203025619_default_lock_version_to_zero_for_epics.rb
new file mode 100644
index 00000000000..f44cfd07ee2
--- /dev/null
+++ b/db/migrate/20200203025619_default_lock_version_to_zero_for_epics.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 DefaultLockVersionToZeroForEpics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ change_column_default :epics, :lock_version, from: nil, to: 0
+ end
+ end
+end
diff --git a/db/migrate/20200203025744_default_lock_version_to_zero_for_ci_builds.rb b/db/migrate/20200203025744_default_lock_version_to_zero_for_ci_builds.rb
new file mode 100644
index 00000000000..feda8c36947
--- /dev/null
+++ b/db/migrate/20200203025744_default_lock_version_to_zero_for_ci_builds.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 DefaultLockVersionToZeroForCiBuilds < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ change_column_default :ci_builds, :lock_version, from: nil, to: 0
+ end
+ end
+end
diff --git a/db/migrate/20200203025801_default_lock_version_to_zero_for_ci_stages.rb b/db/migrate/20200203025801_default_lock_version_to_zero_for_ci_stages.rb
new file mode 100644
index 00000000000..b825c4ff1c4
--- /dev/null
+++ b/db/migrate/20200203025801_default_lock_version_to_zero_for_ci_stages.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 DefaultLockVersionToZeroForCiStages < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ change_column_default :ci_stages, :lock_version, from: nil, to: 0
+ end
+ end
+end
diff --git a/db/migrate/20200203025821_default_lock_version_to_zero_for_ci_pipelines.rb b/db/migrate/20200203025821_default_lock_version_to_zero_for_ci_pipelines.rb
new file mode 100644
index 00000000000..6c4c84cb7e7
--- /dev/null
+++ b/db/migrate/20200203025821_default_lock_version_to_zero_for_ci_pipelines.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 DefaultLockVersionToZeroForCiPipelines < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ with_lock_retries do
+ change_column_default :ci_pipelines, :lock_version, from: nil, to: 0
+ end
+ end
+end
diff --git a/db/migrate/20200203173508_add_confirmed_attributes_to_vulnerabilities.rb b/db/migrate/20200203173508_add_confirmed_attributes_to_vulnerabilities.rb
new file mode 100644
index 00000000000..43a375c011f
--- /dev/null
+++ b/db/migrate/20200203173508_add_confirmed_attributes_to_vulnerabilities.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddConfirmedAttributesToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerabilities, :confirmed_by_id, :bigint
+ add_column :vulnerabilities, :confirmed_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20200203183508_add_index_for_vulnerability_confirmed_by.rb b/db/migrate/20200203183508_add_index_for_vulnerability_confirmed_by.rb
new file mode 100644
index 00000000000..dd50e7be893
--- /dev/null
+++ b/db/migrate/20200203183508_add_index_for_vulnerability_confirmed_by.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexForVulnerabilityConfirmedBy < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerabilities, :confirmed_by_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :confirmed_by_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key :vulnerabilities, column: :confirmed_by_id
+ remove_concurrent_index :vulnerabilities, :confirmed_by_id
+ end
+end
diff --git a/db/migrate/20200203232433_create_security_scan.rb b/db/migrate/20200203232433_create_security_scan.rb
new file mode 100644
index 00000000000..a5fe73efbf2
--- /dev/null
+++ b/db/migrate/20200203232433_create_security_scan.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateSecurityScan < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :security_scans, id: :bigserial do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :build,
+ null: false,
+ index: false,
+ foreign_key: { to_table: :ci_builds, on_delete: :cascade },
+ type: :bigint
+
+ t.integer :scan_type,
+ null: false,
+ index: { name: "idx_security_scans_on_scan_type" },
+ limit: 2
+
+ t.index [:build_id, :scan_type], name: "idx_security_scans_on_build_and_scan_type", unique: true
+ end
+ end
+end
diff --git a/db/migrate/20200204070729_add_elasticsearch_indexed_field_length_limit_to_application_settings.rb b/db/migrate/20200204070729_add_elasticsearch_indexed_field_length_limit_to_application_settings.rb
new file mode 100644
index 00000000000..7d478706613
--- /dev/null
+++ b/db/migrate/20200204070729_add_elasticsearch_indexed_field_length_limit_to_application_settings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddElasticsearchIndexedFieldLengthLimitToApplicationSettings < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ add_column :application_settings, :elasticsearch_indexed_field_length_limit, :integer, null: false, default: 0
+
+ if Gitlab.com?
+ execute 'UPDATE application_settings SET elasticsearch_indexed_field_length_limit = 20000'
+ end
+ end
+
+ def down
+ remove_column :application_settings, :elasticsearch_indexed_field_length_limit
+ end
+end
diff --git a/db/migrate/20200204131054_change_broadcast_message_index.rb b/db/migrate/20200204131054_change_broadcast_message_index.rb
new file mode 100644
index 00000000000..9545eacd3a1
--- /dev/null
+++ b/db/migrate/20200204131054_change_broadcast_message_index.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class ChangeBroadcastMessageIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :broadcast_messages, %i(ends_at broadcast_type id), name: 'index_broadcast_message_on_ends_at_and_broadcast_type_and_id'
+ remove_concurrent_index_by_name :broadcast_messages, :index_broadcast_messages_on_starts_at_and_ends_at_and_id
+ end
+
+ def down
+ add_concurrent_index :broadcast_messages, %i(starts_at ends_at id), name: 'index_broadcast_messages_on_starts_at_and_ends_at_and_id'
+ remove_concurrent_index_by_name :broadcast_messages, :index_broadcast_message_on_ends_at_and_broadcast_type_and_id
+ end
+end
diff --git a/db/migrate/20200205143231_add_dissmised_at_to_user_callouts.rb b/db/migrate/20200205143231_add_dissmised_at_to_user_callouts.rb
new file mode 100644
index 00000000000..f9942d442b5
--- /dev/null
+++ b/db/migrate/20200205143231_add_dissmised_at_to_user_callouts.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddDissmisedAtToUserCallouts < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :user_callouts, :dismissed_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20200206112850_create_snippet_repository_table.rb b/db/migrate/20200206112850_create_snippet_repository_table.rb
new file mode 100644
index 00000000000..0c14b37855d
--- /dev/null
+++ b/db/migrate/20200206112850_create_snippet_repository_table.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :snippet_repositories, id: false, primary_key: :snippet_id do |t|
+ t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
+ t.references :snippet, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade }
+ t.string :disk_path, limit: 80, null: false, index: { unique: true }
+ end
+ end
+end
diff --git a/db/migrate/20200207090921_add_nuget_index_to_packages_packages.rb b/db/migrate/20200207090921_add_nuget_index_to_packages_packages.rb
new file mode 100644
index 00000000000..1bd9c4dc0d0
--- /dev/null
+++ b/db/migrate/20200207090921_add_nuget_index_to_packages_packages.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddNugetIndexToPackagesPackages < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_packages_project_id_name_partial_for_nuget'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :packages_packages, [:project_id, :name], name: INDEX_NAME, where: "name <> 'NuGet.Temporary.Package' AND version is not null AND package_type = 4"
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_packages, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20200207132752_add_es_bulk_config.rb b/db/migrate/20200207132752_add_es_bulk_config.rb
new file mode 100644
index 00000000000..c460971139c
--- /dev/null
+++ b/db/migrate/20200207132752_add_es_bulk_config.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddEsBulkConfig < ActiveRecord::Migration[6.0]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :elasticsearch_max_bulk_size_mb, :smallint, null: false, default: 10
+ add_column :application_settings, :elasticsearch_max_bulk_concurrency, :smallint, null: false, default: 10
+ end
+end
diff --git a/db/migrate/20200207151640_create_deployment_clusters.rb b/db/migrate/20200207151640_create_deployment_clusters.rb
new file mode 100644
index 00000000000..233e91d31b0
--- /dev/null
+++ b/db/migrate/20200207151640_create_deployment_clusters.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateDeploymentClusters < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :deployment_clusters, id: false, force: :cascade do |t|
+ t.references :deployment, foreign_key: { on_delete: :cascade }, primary_key: true, type: :integer, index: false, default: nil
+ t.references :cluster, foreign_key: { on_delete: :cascade }, type: :integer, index: false, null: false
+ t.string :kubernetes_namespace, limit: 255
+
+ t.index [:cluster_id, :kubernetes_namespace], name: 'idx_deployment_clusters_on_cluster_id_and_kubernetes_namespace'
+ t.index [:cluster_id, :deployment_id], unique: true
+ end
+ end
+end
diff --git a/db/migrate/20200207182131_replace_conan_metadata_index.rb b/db/migrate/20200207182131_replace_conan_metadata_index.rb
new file mode 100644
index 00000000000..4f55a2974d8
--- /dev/null
+++ b/db/migrate/20200207182131_replace_conan_metadata_index.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class ReplaceConanMetadataIndex < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ OLD_INDEX = 'index_packages_conan_metadata_on_package_id'
+ NEW_INDEX = 'index_packages_conan_metadata_on_package_id_username_channel'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :packages_conan_metadata,
+ [:package_id, :package_username, :package_channel],
+ unique: true, name: NEW_INDEX
+
+ remove_concurrent_index_by_name :packages_conan_metadata, OLD_INDEX
+ end
+
+ def down
+ add_concurrent_index :packages_conan_metadata, :package_id, name: OLD_INDEX
+
+ remove_concurrent_index_by_name :packages_conan_metadata, NEW_INDEX
+ end
+end
diff --git a/db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb b/db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb
new file mode 100644
index 00000000000..c05b624c438
--- /dev/null
+++ b/db/migrate/20200209131152_add_feature_filter_type_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddFeatureFilterTypeToUserPreferences < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :user_preferences, :feature_filter_type, :bigint
+ end
+end
diff --git a/db/migrate/20200210135504_remove_packages_deprecated_dependencies.rb b/db/migrate/20200210135504_remove_packages_deprecated_dependencies.rb
new file mode 100644
index 00000000000..476b3de659a
--- /dev/null
+++ b/db/migrate/20200210135504_remove_packages_deprecated_dependencies.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RemovePackagesDeprecatedDependencies < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ execute('DELETE FROM packages_dependency_links WHERE dependency_type = 5')
+ end
+
+ def down
+ # There is nothing to do to reverse this migration
+ end
+end
diff --git a/db/migrate/20200210184410_create_operations_strategies_table.rb b/db/migrate/20200210184410_create_operations_strategies_table.rb
new file mode 100644
index 00000000000..1046bd11bc7
--- /dev/null
+++ b/db/migrate/20200210184410_create_operations_strategies_table.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :operations_strategies do |t|
+ t.references :feature_flag, index: true, null: false, foreign_key: { to_table: :operations_feature_flags, on_delete: :cascade }
+ t.string :name, null: false, limit: 255
+ t.jsonb :parameters, null: false, default: {}
+ end
+ end
+end
diff --git a/db/migrate/20200210184420_create_operations_scopes_table.rb b/db/migrate/20200210184420_create_operations_scopes_table.rb
new file mode 100644
index 00000000000..0b33882fe3d
--- /dev/null
+++ b/db/migrate/20200210184420_create_operations_scopes_table.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreateOperationsScopesTable < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ create_table :operations_scopes do |t|
+ t.references :strategy, null: false, index: false, foreign_key: { to_table: :operations_strategies, on_delete: :cascade }
+ t.string :environment_scope, null: false, limit: 255
+ end
+
+ add_index :operations_scopes, [:strategy_id, :environment_scope], unique: true
+ end
+end
diff --git a/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb b/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb
new file mode 100644
index 00000000000..97f2e568a7e
--- /dev/null
+++ b/db/post_migrate/20191115115043_migrate_epic_mentions_to_db.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class MigrateEpicMentionsToDb < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ DELAY = 2.minutes.to_i
+ BATCH_SIZE = 10000
+ MIGRATION = 'UserMentions::CreateResourceUserMention'
+
+ JOIN = "LEFT JOIN epic_user_mentions on epics.id = epic_user_mentions.epic_id"
+ QUERY_CONDITIONS = "(description like '%@%' OR title like '%@%') AND epic_user_mentions.epic_id is null"
+
+ class Epic < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'epics'
+ end
+
+ def up
+ return unless Gitlab.ee?
+
+ Epic
+ .joins(JOIN)
+ .where(QUERY_CONDITIONS)
+ .each_batch(of: BATCH_SIZE) do |batch, index|
+ range = batch.pluck(Arel.sql('MIN(epics.id)'), Arel.sql('MAX(epics.id)')).first
+ BackgroundMigrationWorker.perform_in(index * DELAY, MIGRATION, ['Epic', JOIN, QUERY_CONDITIONS, false, *range])
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20191115115522_migrate_epic_notes_mentions_to_db.rb b/db/post_migrate/20191115115522_migrate_epic_notes_mentions_to_db.rb
new file mode 100644
index 00000000000..7914ff59dbd
--- /dev/null
+++ b/db/post_migrate/20191115115522_migrate_epic_notes_mentions_to_db.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+class MigrateEpicNotesMentionsToDb < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ DELAY = 2.minutes.to_i
+ BATCH_SIZE = 10000
+ MIGRATION = 'UserMentions::CreateResourceUserMention'
+
+ INDEX_NAME = 'epic_mentions_temp_index'
+ INDEX_CONDITION = "note LIKE '%@%'::text AND notes.noteable_type = 'Epic'"
+ QUERY_CONDITIONS = "#{INDEX_CONDITION} AND epic_user_mentions.epic_id IS NULL"
+ JOIN = 'INNER JOIN epics ON epics.id = notes.noteable_id LEFT JOIN epic_user_mentions ON notes.id = epic_user_mentions.note_id'
+
+ class Note < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'notes'
+ end
+
+ def up
+ return unless Gitlab.ee?
+
+ # create temporary index for notes with mentions, may take well over 1h
+ add_concurrent_index(:notes, :id, where: INDEX_CONDITION, name: INDEX_NAME)
+
+ Note
+ .joins(JOIN)
+ .where(QUERY_CONDITIONS)
+ .each_batch(of: BATCH_SIZE) do |batch, index|
+ range = batch.pluck(Arel.sql('MIN(notes.id)'), Arel.sql('MAX(notes.id)')).first
+ BackgroundMigrationWorker.perform_in(index * DELAY, MIGRATION, ['Epic', JOIN, QUERY_CONDITIONS, true, *range])
+ end
+ end
+
+ def down
+ # no-op
+ # temporary index is to be dropped in a different migration in an upcoming release:
+ # https://gitlab.com/gitlab-org/gitlab/issues/196842
+ end
+end
diff --git a/db/post_migrate/20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb b/db/post_migrate/20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb
index df5c6c8f6cc..c2e6792e611 100644
--- a/db/post_migrate/20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb
+++ b/db/post_migrate/20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb
@@ -12,6 +12,6 @@ class DropProjectCiCdSettingsMergeTrainsEnabled < ActiveRecord::Migration[5.2]
end
def down
- add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: true
+ add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: true # rubocop:disable Migration/UpdateLargeTable
end
end
diff --git a/db/post_migrate/20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb b/db/post_migrate/20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb
new file mode 100644
index 00000000000..813cd600ddc
--- /dev/null
+++ b/db/post_migrate/20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb
@@ -0,0 +1,56 @@
+# 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 ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ MIGRATION = 'UpdateExistingSubgroupToMatchVisibilityLevelOfParent'
+ DELAY_INTERVAL = 5.minutes.to_i
+ BATCH_SIZE = 1000
+ VISIBILITY_LEVELS = {
+ internal: 10,
+ private: 0
+ }
+
+ disable_ddl_transaction!
+
+ def up
+ offset = update_groups(VISIBILITY_LEVELS[:internal])
+ update_groups(VISIBILITY_LEVELS[:private], offset: offset)
+ end
+
+ def down
+ # no-op
+ end
+
+ private
+
+ def update_groups(level, offset: 0)
+ groups = exec_query <<~SQL
+ SELECT id
+ FROM namespaces
+ WHERE visibility_level = #{level}
+ AND type = 'Group'
+ AND EXISTS (SELECT 1
+ FROM namespaces AS children
+ WHERE children.parent_id = namespaces.id)
+ SQL
+
+ ids = groups.rows.flatten
+
+ iterator = 1
+
+ ids.in_groups_of(BATCH_SIZE, false) do |batch_of_ids|
+ delay = DELAY_INTERVAL * (iterator + offset)
+ BackgroundMigrationWorker.perform_in(delay, MIGRATION, [batch_of_ids, level])
+ iterator += 1
+ end
+
+ say("Background jobs for visibility level #{level} scheduled in #{iterator} iterations")
+
+ offset + iterator
+ end
+end
diff --git a/db/post_migrate/20200114113341_patch_prometheus_services_for_shared_cluster_applications.rb b/db/post_migrate/20200114113341_patch_prometheus_services_for_shared_cluster_applications.rb
index 68361f7b176..d49bd10887c 100644
--- a/db/post_migrate/20200114113341_patch_prometheus_services_for_shared_cluster_applications.rb
+++ b/db/post_migrate/20200114113341_patch_prometheus_services_for_shared_cluster_applications.rb
@@ -1,88 +1,11 @@
# frozen_string_literal: true
class PatchPrometheusServicesForSharedClusterApplications < ActiveRecord::Migration[5.2]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- MIGRATION = 'ActivatePrometheusServicesForSharedClusterApplications'.freeze
- BATCH_SIZE = 500
- DELAY = 2.minutes
-
- disable_ddl_transaction!
-
- module Migratable
- module Applications
- class Prometheus < ActiveRecord::Base
- self.table_name = 'clusters_applications_prometheus'
-
- enum status: {
- errored: -1,
- installed: 3,
- updated: 5
- }
- end
- end
-
- class Project < ActiveRecord::Base
- self.table_name = 'projects'
- include ::EachBatch
-
- scope :with_application_on_group_clusters, -> {
- joins("INNER JOIN namespaces ON namespaces.id = projects.namespace_id")
- .joins("INNER JOIN cluster_groups ON cluster_groups.group_id = namespaces.id")
- .joins("INNER JOIN clusters ON clusters.id = cluster_groups.cluster_id AND clusters.cluster_type = #{Cluster.cluster_types['group_type']}")
- .joins("INNER JOIN clusters_applications_prometheus ON clusters_applications_prometheus.cluster_id = clusters.id
- AND clusters_applications_prometheus.status IN (#{Applications::Prometheus.statuses[:installed]}, #{Applications::Prometheus.statuses[:updated]})")
- }
-
- scope :without_active_prometheus_services, -> {
- joins("LEFT JOIN services ON services.project_id = projects.id AND services.type = 'PrometheusService'")
- .where("services.id IS NULL OR (services.active = FALSE AND services.properties = '{}')")
- }
- end
-
- class Cluster < ActiveRecord::Base
- self.table_name = 'clusters'
-
- enum cluster_type: {
- instance_type: 1,
- group_type: 2
- }
-
- def self.has_prometheus_application?
- joins("INNER JOIN clusters_applications_prometheus ON clusters_applications_prometheus.cluster_id = clusters.id
- AND clusters_applications_prometheus.status IN (#{Applications::Prometheus.statuses[:installed]}, #{Applications::Prometheus.statuses[:updated]})").exists?
- end
- end
- end
-
def up
- projects_without_active_prometheus_service.group('projects.id').each_batch(of: BATCH_SIZE) do |batch, index|
- bg_migrations_batch = batch.select('projects.id').map { |project| [MIGRATION, project.id] }
- delay = index * DELAY
- BackgroundMigrationWorker.bulk_perform_in(delay.seconds, bg_migrations_batch)
- end
+ # no-op
end
def down
# no-op
end
-
- private
-
- def projects_without_active_prometheus_service
- scope = Migratable::Project.without_active_prometheus_services
-
- return scope if migrate_instance_cluster?
-
- scope.with_application_on_group_clusters
- end
-
- def migrate_instance_cluster?
- if instance_variable_defined?('@migrate_instance_cluster')
- @migrate_instance_cluster
- else
- @migrate_instance_cluster = Migratable::Cluster.instance_type.has_prometheus_application?
- end
- end
end
diff --git a/db/post_migrate/20200117194850_backfill_operations_feature_flags_iid.rb b/db/post_migrate/20200117194850_backfill_operations_feature_flags_iid.rb
new file mode 100644
index 00000000000..bc97bd6062d
--- /dev/null
+++ b/db/post_migrate/20200117194850_backfill_operations_feature_flags_iid.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class BackfillOperationsFeatureFlagsIid < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ ###
+ # This should update about 700 rows on gitlab.com
+ # Execution time is predicted to take less than a second based on #database-lab results
+ # https://gitlab.com/gitlab-org/gitlab/merge_requests/22175#migration-performance
+ ###
+ def up
+ execute('LOCK operations_feature_flags IN ACCESS EXCLUSIVE MODE')
+
+ backfill_iids('operations_feature_flags')
+
+ change_column_null :operations_feature_flags, :iid, false
+ end
+
+ def down
+ change_column_null :operations_feature_flags, :iid, true
+ end
+end
diff --git a/db/post_migrate/20200117194900_delete_internal_ids_where_feature_flags_usage.rb b/db/post_migrate/20200117194900_delete_internal_ids_where_feature_flags_usage.rb
new file mode 100644
index 00000000000..0cf1ab03622
--- /dev/null
+++ b/db/post_migrate/20200117194900_delete_internal_ids_where_feature_flags_usage.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class DeleteInternalIdsWhereFeatureFlagsUsage < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ sql = <<~SQL
+ DELETE FROM internal_ids WHERE usage = 6
+ SQL
+
+ execute(sql)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb b/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb
new file mode 100644
index 00000000000..62bb3f46cae
--- /dev/null
+++ b/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb
@@ -0,0 +1,30 @@
+# 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 RemoveStorageVersionColumnFromSnippets < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ return unless column_exists?(:snippets, :storage_version)
+
+ remove_column :snippets, :storage_version
+ end
+
+ def down
+ return if column_exists?(:snippets, :storage_version)
+
+ add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault
+ :snippets,
+ :storage_version,
+ :integer,
+ default: 2,
+ allow_null: false
+ )
+ end
+end
diff --git a/db/post_migrate/20200122123016_backfill_project_settings.rb b/db/post_migrate/20200122123016_backfill_project_settings.rb
new file mode 100644
index 00000000000..80ca79e979e
--- /dev/null
+++ b/db/post_migrate/20200122123016_backfill_project_settings.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class BackfillProjectSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ MIGRATION = 'BackfillProjectSettings'
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 10_000
+
+ disable_ddl_transaction!
+
+ class Project < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'projects'
+ end
+
+ def up
+ say "Scheduling `#{MIGRATION}` jobs"
+
+ queue_background_migration_jobs_by_range_at_intervals(Project, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
+ end
+
+ def down
+ # NOOP
+ end
+end
diff --git a/db/post_migrate/20200122144759_drop_kibana_column.rb b/db/post_migrate/20200122144759_drop_kibana_column.rb
new file mode 100644
index 00000000000..ce94ca2dc27
--- /dev/null
+++ b/db/post_migrate/20200122144759_drop_kibana_column.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class DropKibanaColumn < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ remove_column :clusters_applications_elastic_stacks, :kibana_hostname, :string, limit: 255
+ end
+end
diff --git a/db/post_migrate/20200127111840_fix_projects_without_project_feature.rb b/db/post_migrate/20200127111840_fix_projects_without_project_feature.rb
new file mode 100644
index 00000000000..66e892444d1
--- /dev/null
+++ b/db/post_migrate/20200127111840_fix_projects_without_project_feature.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ BATCH_SIZE = 50_000
+ MIGRATION = 'FixProjectsWithoutProjectFeature'
+
+ disable_ddl_transaction!
+
+ class Project < ActiveRecord::Base
+ include EachBatch
+ end
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(Project, MIGRATION, 2.minutes, batch_size: BATCH_SIZE)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb b/db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb
new file mode 100644
index 00000000000..d1d2b4962dd
--- /dev/null
+++ b/db/post_migrate/20200129035708_cleanup_rename_pages_domains_domain_type_to_scope.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CleanupRenamePagesDomainsDomainTypeToScope < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :pages_domains, :domain_type, :scope
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :pages_domains, :domain_type, :scope
+ end
+end
diff --git a/db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb b/db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb
new file mode 100644
index 00000000000..312a8c95b92
--- /dev/null
+++ b/db/post_migrate/20200130145430_reschedule_migrate_issue_trackers_data.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+class RescheduleMigrateIssueTrackersData < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INTERVAL = 3.minutes.to_i
+ BATCH_SIZE = 5_000
+ MIGRATION = 'MigrateIssueTrackersSensitiveData'
+
+ disable_ddl_transaction!
+
+ class Service < ActiveRecord::Base
+ self.table_name = 'services'
+ self.inheritance_column = :_type_disabled
+
+ include ::EachBatch
+ end
+
+ def up
+ relation = Service.where(category: 'issue_tracker').where("properties IS NOT NULL AND properties != '{}' AND properties != ''")
+ queue_background_migration_jobs_by_range_at_intervals(relation,
+ MIGRATION,
+ INTERVAL,
+ batch_size: BATCH_SIZE)
+ end
+
+ def down
+ remove_issue_tracker_data_sql = "DELETE FROM issue_tracker_data WHERE \
+ (length(encrypted_issues_url) > 0 AND encrypted_issues_url_iv IS NULL) \
+ OR (length(encrypted_new_issue_url) > 0 AND encrypted_new_issue_url_iv IS NULL) \
+ OR (length(encrypted_project_url) > 0 AND encrypted_project_url_iv IS NULL)"
+
+ execute(remove_issue_tracker_data_sql)
+
+ remove_jira_tracker_data_sql = "DELETE FROM jira_tracker_data WHERE \
+ (length(encrypted_api_url) > 0 AND encrypted_api_url_iv IS NULL) \
+ OR (length(encrypted_url) > 0 AND encrypted_url_iv IS NULL) \
+ OR (length(encrypted_username) > 0 AND encrypted_username_iv IS NULL) \
+ OR (length(encrypted_password) > 0 AND encrypted_password_iv IS NULL)"
+
+ execute(remove_jira_tracker_data_sql)
+ end
+end
diff --git a/db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.rb b/db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.rb
new file mode 100644
index 00000000000..c9566d0256c
--- /dev/null
+++ b/db/post_migrate/20200203104214_services_remove_temporary_index_on_project_id.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 ServicesRemoveTemporaryIndexOnProjectId < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'tmp_index_on_project_id_partial_with_prometheus_services'
+ PARTIAL_FILTER = "type = 'PrometheusService'"
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index :services, :project_id, where: PARTIAL_FILTER, name: INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :services, :project_id, where: PARTIAL_FILTER, name: INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20200206091544_migrate_create_commit_signature_worker_sidekiq_queue.rb b/db/post_migrate/20200206091544_migrate_create_commit_signature_worker_sidekiq_queue.rb
new file mode 100644
index 00000000000..eec9abf4a31
--- /dev/null
+++ b/db/post_migrate/20200206091544_migrate_create_commit_signature_worker_sidekiq_queue.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class MigrateCreateCommitSignatureWorkerSidekiqQueue < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ sidekiq_queue_migrate 'create_gpg_signature', to: 'create_commit_signature'
+ end
+
+ def down
+ sidekiq_queue_migrate 'create_commit_signature', to: 'create_gpg_signature'
+ end
+end
diff --git a/db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb b/db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb
new file mode 100644
index 00000000000..ddaa3049543
--- /dev/null
+++ b/db/post_migrate/20200206135203_udpate_index_ci_builds_on_name_for_security_products.rb
@@ -0,0 +1,33 @@
+# 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 UdpateIndexCiBuildsOnNameForSecurityProducts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_ci_builds_on_name_for_security_products_values'
+ INDEX_NAME_NEW = 'index_ci_builds_on_name_for_security_reports_values'
+ INITIAL_INDEX = "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text"
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:ci_builds,
+ :name,
+ name: INDEX_NAME_NEW,
+ where: INITIAL_INDEX + ", ('license_scanning'::character varying)::text]))")
+
+ remove_concurrent_index_by_name(:ci_builds, INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:ci_builds,
+ :name,
+ name: INDEX_NAME,
+ where: INITIAL_INDEX + ']))')
+
+ remove_concurrent_index_by_name(:ci_builds, INDEX_NAME_NEW)
+ end
+end
diff --git a/db/post_migrate/20200207184023_add_temporary_index_to_promotion_notes.rb b/db/post_migrate/20200207184023_add_temporary_index_to_promotion_notes.rb
new file mode 100644
index 00000000000..44a32938483
--- /dev/null
+++ b/db/post_migrate/20200207184023_add_temporary_index_to_promotion_notes.rb
@@ -0,0 +1,23 @@
+# 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 AddTemporaryIndexToPromotionNotes < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :notes,
+ :note,
+ where: "noteable_type = 'Issue' AND system IS TRUE AND note LIKE 'promoted to epic%'",
+ name: 'tmp_idx_on_promoted_notes'
+ end
+
+ def down
+ # NO OP
+ end
+end
diff --git a/db/post_migrate/20200207185149_schedule_fix_orphan_promoted_issues.rb b/db/post_migrate/20200207185149_schedule_fix_orphan_promoted_issues.rb
new file mode 100644
index 00000000000..83ba56501dd
--- /dev/null
+++ b/db/post_migrate/20200207185149_schedule_fix_orphan_promoted_issues.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class ScheduleFixOrphanPromotedIssues < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 100
+ BACKGROUND_MIGRATION = 'FixOrphanPromotedIssues'.freeze
+
+ disable_ddl_transaction!
+
+ class Note < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'notes'
+
+ scope :of_promotion, -> do
+ where(noteable_type: 'Issue')
+ .where('notes.system IS TRUE')
+ .where("notes.note LIKE 'promoted to epic%'")
+ end
+ end
+
+ def up
+ Note.of_promotion.each_batch(of: BATCH_SIZE) do |notes, index|
+ jobs = notes.map { |note| [BACKGROUND_MIGRATION, [note.id]] }
+
+ BackgroundMigrationWorker.bulk_perform_async(jobs)
+ end
+ end
+
+ def down
+ # NO OP
+ end
+end
diff --git a/db/post_migrate/20200210062432_schedule_link_lfs_objects.rb b/db/post_migrate/20200210062432_schedule_link_lfs_objects.rb
new file mode 100644
index 00000000000..b401065dd94
--- /dev/null
+++ b/db/post_migrate/20200210062432_schedule_link_lfs_objects.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ScheduleLinkLfsObjects < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # no-op as background migration being schedule times out in some instances
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20200210092405_save_instance_administrators_group_id.rb b/db/post_migrate/20200210092405_save_instance_administrators_group_id.rb
new file mode 100644
index 00000000000..e539a187672
--- /dev/null
+++ b/db/post_migrate/20200210092405_save_instance_administrators_group_id.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+class SaveInstanceAdministratorsGroupId < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def up
+ execute(
+ <<-SQL
+ UPDATE
+ application_settings
+ SET
+ instance_administrators_group_id = (
+ SELECT
+ namespace_id
+ FROM
+ projects
+ WHERE
+ id = application_settings.instance_administration_project_id
+ )
+ WHERE
+ instance_administrators_group_id IS NULL
+ AND
+ instance_administration_project_id IS NOT NULL
+ AND
+ ID in (
+ SELECT
+ max(id)
+ FROM
+ application_settings
+ )
+ SQL
+ )
+ end
+
+ def down
+ # no-op
+
+ # The change performed by `up` cannot be reversed because once the migration runs,
+ # we do not know what value application_settings.instance_administrators_group_id
+ # had before the migration was run.
+ end
+end
diff --git a/db/post_migrate/20200211152410_remove_instance_from_services.rb b/db/post_migrate/20200211152410_remove_instance_from_services.rb
new file mode 100644
index 00000000000..1f27455b541
--- /dev/null
+++ b/db/post_migrate/20200211152410_remove_instance_from_services.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemoveInstanceFromServices < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ return unless column_exists?(:services, :instance)
+
+ undo_rename_column_concurrently :services, :template, :instance
+ end
+
+ def down
+ # This migration should not be rolled back because it
+ # removes a column that got added in migrations that
+ # have been reverted in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24857
+ end
+end
diff --git a/db/post_migrate/20200212052620_readd_template_column_to_services.rb b/db/post_migrate/20200212052620_readd_template_column_to_services.rb
new file mode 100644
index 00000000000..e54b9e39277
--- /dev/null
+++ b/db/post_migrate/20200212052620_readd_template_column_to_services.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class ReaddTemplateColumnToServices < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ return if column_exists? :services, :template
+
+ # The migration to drop the template column never actually shipped
+ # to production, so we should be okay to re-add it without worrying
+ # about doing a data migration. If we needed to restore the value
+ # of `template`, we would look for entries with `project_id IS NULL`.
+ add_column_with_default :services, :template, :boolean, default: false, allow_null: true
+ end
+
+ def down
+ # NOP since the column is expected to exist
+ end
+end
diff --git a/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb b/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb
new file mode 100644
index 00000000000..19b3af53836
--- /dev/null
+++ b/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb
@@ -0,0 +1,30 @@
+# 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 RemoveUnnecessaryMilestoneJoinTables < ActiveRecord::Migration[6.0]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def up
+ drop_table :issue_milestones
+ drop_table :merge_request_milestones
+ end
+
+ def down
+ create_table :issue_milestones, id: false do |t|
+ t.references :issue, foreign_key: { on_delete: :cascade }, index: { unique: true }, null: false
+ t.references :milestone, foreign_key: { on_delete: :cascade }, index: true, null: false
+ end
+
+ add_index :issue_milestones, [:issue_id, :milestone_id], unique: true
+
+ create_table :merge_request_milestones, id: false do |t|
+ t.references :merge_request, foreign_key: { on_delete: :cascade }, index: { unique: true }, null: false
+ t.references :milestone, foreign_key: { on_delete: :cascade }, index: true, null: false
+ end
+
+ add_index :merge_request_milestones, [:merge_request_id, :milestone_id], name: 'index_mrs_milestones_on_mr_id_and_milestone_id', unique: true
+ end
+end
diff --git a/db/post_migrate/20200213220159_migrate_store_security_reports_sidekiq_queue.rb b/db/post_migrate/20200213220159_migrate_store_security_reports_sidekiq_queue.rb
new file mode 100644
index 00000000000..5bba4c95328
--- /dev/null
+++ b/db/post_migrate/20200213220159_migrate_store_security_reports_sidekiq_queue.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class MigrateStoreSecurityReportsSidekiqQueue < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ sidekiq_queue_migrate 'pipeline_default:store_security_reports', to: 'security_scans:store_security_reports'
+ end
+
+ def down
+ sidekiq_queue_migrate 'security_scans:store_security_reports', to: 'pipeline_default:store_security_reports'
+ end
+end
diff --git a/db/post_migrate/20200213220211_migrate_sync_security_reports_to_report_approval_rules_sidekiq_queue.rb b/db/post_migrate/20200213220211_migrate_sync_security_reports_to_report_approval_rules_sidekiq_queue.rb
new file mode 100644
index 00000000000..e3ed4c60f21
--- /dev/null
+++ b/db/post_migrate/20200213220211_migrate_sync_security_reports_to_report_approval_rules_sidekiq_queue.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class MigrateSyncSecurityReportsToReportApprovalRulesSidekiqQueue < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ sidekiq_queue_migrate 'pipeline_default:sync_security_reports_to_report_approval_rules',
+ to: 'security_scans:sync_security_reports_to_report_approval_rules'
+ end
+
+ def down
+ sidekiq_queue_migrate 'security_scans:sync_security_reports_to_report_approval_rules',
+ to: 'pipeline_default:sync_security_reports_to_report_approval_rules'
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 41bebdb8eac..435d994e201 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2,15 +2,15 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
+# This file is the source Rails uses to define your schema when running `rails
+# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
+# be faster and is potentially less error prone than running all of your
+# migrations from scratch. Old migrations may fail to apply correctly if those
+# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2020_02_04_113223) do
+ActiveRecord::Schema.define(version: 2020_02_13_220211) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -94,30 +94,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["project_id"], name: "analytics_repository_languages_on_project_id"
end
- create_table "analytics_repository_file_commits", force: :cascade do |t|
- t.bigint "analytics_repository_file_id", null: false
- t.bigint "project_id", null: false
- t.date "committed_date", null: false
- t.integer "commit_count", limit: 2, null: false
- t.index ["analytics_repository_file_id"], name: "index_analytics_repository_file_commits_file_id"
- t.index ["project_id", "committed_date", "analytics_repository_file_id"], name: "index_file_commits_on_committed_date_file_id_and_project_id", unique: true
- end
-
- create_table "analytics_repository_file_edits", force: :cascade do |t|
- t.bigint "project_id", null: false
- t.bigint "analytics_repository_file_id", null: false
- t.date "committed_date", null: false
- t.integer "num_edits", default: 0, null: false
- t.index ["analytics_repository_file_id", "committed_date", "project_id"], name: "index_file_edits_on_committed_date_file_id_and_project_id", unique: true
- t.index ["project_id"], name: "index_analytics_repository_file_edits_on_project_id"
- end
-
- create_table "analytics_repository_files", force: :cascade do |t|
- t.bigint "project_id", null: false
- t.string "file_path", limit: 4096, null: false
- t.index ["project_id", "file_path"], name: "index_analytics_repository_files_on_project_id_and_file_path", unique: true
- end
-
create_table "appearances", id: :serial, force: :cascade do |t|
t.string "title", null: false
t.text "description", null: false
@@ -367,6 +343,12 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.boolean "force_pages_access_control", default: false, null: false
t.boolean "updating_name_disabled_for_users", default: false, null: false
t.integer "instance_administrators_group_id"
+ t.integer "elasticsearch_indexed_field_length_limit", default: 0, null: false
+ t.integer "elasticsearch_max_bulk_size_mb", limit: 2, default: 10, null: false
+ t.integer "elasticsearch_max_bulk_concurrency", limit: 2, default: 10, null: false
+ t.boolean "disable_overriding_approvers_per_merge_request", default: false, null: false
+ t.boolean "prevent_merge_requests_author_approval", default: false, null: false
+ t.boolean "prevent_merge_requests_committers_approval", default: false, null: false
t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id"
t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id"
t.index ["instance_administration_project_id"], name: "index_applicationsettings_on_instance_administration_project_id"
@@ -489,7 +471,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime "created_at"
t.datetime "updated_at"
t.index ["created_at", "author_id"], name: "analytics_index_audit_events_on_created_at_and_author_id"
- t.index ["entity_id", "entity_type"], name: "index_audit_events_on_entity_id_and_entity_type"
+ t.index ["entity_id", "entity_type", "id"], name: "index_audit_events_on_entity_id_and_entity_type_and_id_desc", order: { id: :desc }
end
create_table "award_emoji", id: :serial, force: :cascade do |t|
@@ -588,7 +570,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "cached_markdown_version"
t.string "target_path", limit: 255
t.integer "broadcast_type", limit: 2, default: 1, null: false
- t.index ["starts_at", "ends_at", "id"], name: "index_broadcast_messages_on_starts_at_and_ends_at_and_id"
+ t.index ["ends_at", "broadcast_type", "id"], name: "index_broadcast_message_on_ends_at_and_broadcast_type_and_id"
end
create_table "chat_names", id: :serial, force: :cascade do |t|
@@ -683,7 +665,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.text "yaml_variables"
t.datetime "queued_at"
t.string "token"
- t.integer "lock_version"
+ t.integer "lock_version", default: 0
t.string "coverage_regex"
t.integer "auto_canceled_by_id"
t.boolean "retried"
@@ -698,6 +680,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.bigint "resource_group_id"
t.datetime_with_timezone "waiting_for_resource_at"
t.boolean "processed"
+ t.integer "scheduling_type", limit: 2
t.index ["artifacts_expire_at"], name: "index_ci_builds_on_artifacts_expire_at", where: "(artifacts_file <> ''::text)"
t.index ["auto_canceled_by_id"], name: "index_ci_builds_on_auto_canceled_by_id"
t.index ["commit_id", "artifacts_expire_at", "id"], name: "index_ci_builds_on_commit_id_and_artifacts_expireatandidpartial", where: "(((type)::text = 'Ci::Build'::text) AND ((retried = false) OR (retried IS NULL)) AND ((name)::text = ANY (ARRAY[('sast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('sast:container'::character varying)::text, ('container_scanning'::character varying)::text, ('dast'::character varying)::text])))"
@@ -705,7 +688,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type"
t.index ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref"
t.index ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref"
- t.index ["name"], name: "index_ci_builds_on_name_for_security_products_values", where: "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text]))"
+ t.index ["name"], name: "index_ci_builds_on_name_for_security_reports_values", where: "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('license_scanning'::character varying)::text]))"
t.index ["project_id", "id"], name: "index_ci_builds_on_project_id_and_id"
t.index ["project_id", "name", "ref"], name: "index_ci_builds_on_project_id_and_name_and_ref", where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = 'success'::text) AND ((retried = false) OR (retried IS NULL)))"
t.index ["project_id", "status"], name: "index_ci_builds_project_id_and_status_for_live_jobs_partial2", where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))"
@@ -859,7 +842,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime "finished_at"
t.integer "duration"
t.integer "user_id"
- t.integer "lock_version"
+ t.integer "lock_version", default: 0
t.integer "auto_canceled_by_id"
t.integer "pipeline_schedule_id"
t.integer "source"
@@ -973,7 +956,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime "updated_at"
t.string "name"
t.integer "status"
- t.integer "lock_version"
+ t.integer "lock_version", default: 0
t.integer "position"
t.index ["pipeline_id", "name"], name: "index_ci_stages_on_pipeline_id_and_name", unique: true
t.index ["pipeline_id", "position"], name: "index_ci_stages_on_pipeline_id_and_position"
@@ -1150,7 +1133,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.bigint "cluster_id", null: false
t.integer "status", null: false
t.string "version", limit: 255, null: false
- t.string "kibana_hostname", limit: 255
t.text "status_reason"
t.index ["cluster_id"], name: "index_clusters_applications_elastic_stacks_on_cluster_id", unique: true
end
@@ -1359,11 +1341,19 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "token"
t.string "username"
t.string "token_encrypted", limit: 255
+ t.integer "deploy_token_type", limit: 2, default: 2, null: false
t.index ["token", "expires_at", "id"], name: "index_deploy_tokens_on_token_and_expires_at_and_id", where: "(revoked IS FALSE)"
t.index ["token"], name: "index_deploy_tokens_on_token", unique: true
t.index ["token_encrypted"], name: "index_deploy_tokens_on_token_encrypted", unique: true
end
+ create_table "deployment_clusters", primary_key: "deployment_id", id: :integer, default: nil, force: :cascade do |t|
+ t.integer "cluster_id", null: false
+ t.string "kubernetes_namespace", limit: 255
+ t.index ["cluster_id", "deployment_id"], name: "index_deployment_clusters_on_cluster_id_and_deployment_id", unique: true
+ t.index ["cluster_id", "kubernetes_namespace"], name: "idx_deployment_clusters_on_cluster_id_and_kubernetes_namespace"
+ end
+
create_table "deployment_merge_requests", id: false, force: :cascade do |t|
t.integer "deployment_id", null: false
t.integer "merge_request_id", null: false
@@ -1410,6 +1400,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "merge_request_id"
t.integer "epic_id"
t.text "description"
+ t.datetime_with_timezone "deleted_at"
t.index ["epic_id"], name: "index_description_versions_on_epic_id", where: "(epic_id IS NOT NULL)"
t.index ["issue_id"], name: "index_description_versions_on_issue_id", where: "(issue_id IS NOT NULL)"
t.index ["merge_request_id"], name: "index_description_versions_on_merge_request_id", where: "(merge_request_id IS NOT NULL)"
@@ -1506,10 +1497,12 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "state", default: "available", null: false
t.string "slug", null: false
t.datetime_with_timezone "auto_stop_at"
+ t.index ["auto_stop_at"], name: "index_environments_on_auto_stop_at", where: "(auto_stop_at IS NOT NULL)"
t.index ["name"], name: "index_environments_on_name_varchar_pattern_ops", opclass: :varchar_pattern_ops
t.index ["project_id", "name"], name: "index_environments_on_project_id_and_name", unique: true
t.index ["project_id", "slug"], name: "index_environments_on_project_id_and_slug", unique: true
t.index ["project_id", "state", "environment_type"], name: "index_environments_on_project_id_state_environment_type"
+ t.index ["state", "auto_stop_at"], name: "index_environments_on_state_and_auto_stop_at", where: "((auto_stop_at IS NOT NULL) AND ((state)::text = 'available'::text))"
end
create_table "epic_issues", id: :serial, force: :cascade do |t|
@@ -1546,7 +1539,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "cached_markdown_version"
t.integer "updated_by_id"
t.integer "last_edited_by_id"
- t.integer "lock_version"
+ t.integer "lock_version", default: 0
t.date "start_date"
t.date "end_date"
t.datetime "last_edited_at"
@@ -1569,6 +1562,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "state_id", limit: 2, default: 1, null: false
t.integer "start_date_sourcing_epic_id"
t.integer "due_date_sourcing_epic_id"
+ t.integer "health_status", limit: 2
t.index ["assignee_id"], name: "index_epics_on_assignee_id"
t.index ["author_id"], name: "index_epics_on_author_id"
t.index ["closed_by_id"], name: "index_epics_on_closed_by_id"
@@ -1688,8 +1682,10 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.bigint "reset_checksum_event_id"
t.bigint "cache_invalidation_event_id"
t.bigint "container_repository_updated_event_id"
+ t.integer "geo_event_id"
t.index ["cache_invalidation_event_id"], name: "index_geo_event_log_on_cache_invalidation_event_id", where: "(cache_invalidation_event_id IS NOT NULL)"
t.index ["container_repository_updated_event_id"], name: "index_geo_event_log_on_container_repository_updated_event_id"
+ t.index ["geo_event_id"], name: "index_geo_event_log_on_geo_event_id", where: "(geo_event_id IS NOT NULL)"
t.index ["hashed_storage_attachments_event_id"], name: "index_geo_event_log_on_hashed_storage_attachments_event_id", where: "(hashed_storage_attachments_event_id IS NOT NULL)"
t.index ["hashed_storage_migrated_event_id"], name: "index_geo_event_log_on_hashed_storage_migrated_event_id", where: "(hashed_storage_migrated_event_id IS NOT NULL)"
t.index ["job_artifact_deleted_event_id"], name: "index_geo_event_log_on_job_artifact_deleted_event_id", where: "(job_artifact_deleted_event_id IS NOT NULL)"
@@ -1703,6 +1699,13 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["upload_deleted_event_id"], name: "index_geo_event_log_on_upload_deleted_event_id", where: "(upload_deleted_event_id IS NOT NULL)"
end
+ create_table "geo_events", force: :cascade do |t|
+ t.string "replicable_name", limit: 255, null: false
+ t.string "event_name", limit: 255, null: false
+ t.jsonb "payload", default: {}, null: false
+ t.datetime_with_timezone "created_at", null: false
+ end
+
create_table "geo_hashed_storage_attachments_events", force: :cascade do |t|
t.integer "project_id", null: false
t.text "old_attachments_path", null: false
@@ -1993,6 +1996,15 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["user_id"], name: "index_group_deletion_schedules_on_user_id"
end
+ create_table "group_deploy_tokens", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.bigint "group_id", null: false
+ t.bigint "deploy_token_id", null: false
+ t.index ["deploy_token_id"], name: "index_group_deploy_tokens_on_deploy_token_id"
+ t.index ["group_id", "deploy_token_id"], name: "index_group_deploy_tokens_on_group_and_deploy_token_ids", unique: true
+ end
+
create_table "group_group_links", force: :cascade do |t|
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
@@ -2045,6 +2057,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "exception_message", limit: 255
t.integer "retry_count"
t.integer "group_id"
+ t.string "source", limit: 128
t.index ["correlation_id_value"], name: "index_import_failures_on_correlation_id_value"
t.index ["group_id"], name: "index_import_failures_on_group_id_not_null", where: "(group_id IS NOT NULL)"
t.index ["project_id"], name: "index_import_failures_on_project_id_not_null", where: "(project_id IS NOT NULL)"
@@ -2115,14 +2128,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["issue_id"], name: "index_issue_metrics"
end
- create_table "issue_milestones", id: false, force: :cascade do |t|
- t.bigint "issue_id", null: false
- t.bigint "milestone_id", null: false
- t.index ["issue_id", "milestone_id"], name: "index_issue_milestones_on_issue_id_and_milestone_id", unique: true
- t.index ["issue_id"], name: "index_issue_milestones_on_issue_id", unique: true
- t.index ["milestone_id"], name: "index_issue_milestones_on_milestone_id"
- end
-
create_table "issue_tracker_data", force: :cascade do |t|
t.integer "service_id", null: false
t.datetime_with_timezone "created_at", null: false
@@ -2162,7 +2167,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.boolean "confidential", default: false, null: false
t.date "due_date"
t.integer "moved_to_id"
- t.integer "lock_version"
+ t.integer "lock_version", default: 0
t.text "title_html"
t.text "description_html"
t.integer "time_estimate"
@@ -2177,6 +2182,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "state_id", limit: 2, default: 1, null: false
t.integer "duplicated_to_id"
t.integer "promoted_to_epic_id"
+ t.integer "health_status", limit: 2
t.index ["author_id"], name: "index_issues_on_author_id"
t.index ["closed_by_id"], name: "index_issues_on_closed_by_id"
t.index ["confidential"], name: "index_issues_on_confidential"
@@ -2351,7 +2357,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime "updated_at"
t.integer "repository_type", limit: 2
t.index ["lfs_object_id"], name: "index_lfs_objects_projects_on_lfs_object_id"
- t.index ["project_id"], name: "index_lfs_objects_projects_on_project_id"
+ t.index ["project_id", "lfs_object_id"], name: "index_lfs_objects_projects_on_project_id_and_lfs_object_id"
end
create_table "licenses", id: :serial, force: :cascade do |t|
@@ -2432,6 +2438,37 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["blocking_merge_request_id", "blocked_merge_request_id"], name: "index_mr_blocks_on_blocking_and_blocked_mr_ids", unique: true
end
+ create_table "merge_request_context_commit_diff_files", id: false, force: :cascade do |t|
+ t.binary "sha", null: false
+ t.integer "relative_order", null: false
+ t.boolean "new_file", null: false
+ t.boolean "renamed_file", null: false
+ t.boolean "deleted_file", null: false
+ t.boolean "too_large", null: false
+ t.string "a_mode", limit: 255, null: false
+ t.string "b_mode", limit: 255, null: false
+ t.text "new_path", null: false
+ t.text "old_path", null: false
+ t.text "diff"
+ t.boolean "binary"
+ t.bigint "merge_request_context_commit_id"
+ t.index ["merge_request_context_commit_id", "sha"], name: "idx_mr_cc_diff_files_on_mr_cc_id_and_sha"
+ end
+
+ create_table "merge_request_context_commits", force: :cascade do |t|
+ t.datetime_with_timezone "authored_date"
+ t.datetime_with_timezone "committed_date"
+ t.integer "relative_order", null: false
+ t.binary "sha", null: false
+ t.text "author_name"
+ t.text "author_email"
+ t.text "committer_name"
+ t.text "committer_email"
+ t.text "message"
+ t.bigint "merge_request_id"
+ t.index ["merge_request_id", "sha"], name: "index_mr_context_commits_on_merge_request_id_and_sha", unique: true
+ end
+
create_table "merge_request_diff_commits", id: false, force: :cascade do |t|
t.datetime "authored_date"
t.datetime "committed_date"
@@ -2510,14 +2547,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id"
end
- create_table "merge_request_milestones", id: false, force: :cascade do |t|
- t.bigint "merge_request_id", null: false
- t.bigint "milestone_id", null: false
- t.index ["merge_request_id", "milestone_id"], name: "index_mrs_milestones_on_mr_id_and_milestone_id", unique: true
- t.index ["merge_request_id"], name: "index_merge_request_milestones_on_merge_request_id", unique: true
- t.index ["milestone_id"], name: "index_merge_request_milestones_on_milestone_id"
- end
-
create_table "merge_request_user_mentions", force: :cascade do |t|
t.integer "merge_request_id", null: false
t.integer "note_id"
@@ -2553,7 +2582,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "approvals_before_merge"
t.string "rebase_commit_sha"
t.string "in_progress_merge_commit_sha"
- t.integer "lock_version"
+ t.integer "lock_version", default: 0
t.text "title_html"
t.text "description_html"
t.integer "time_estimate"
@@ -2615,6 +2644,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "target_project_id", null: false
t.text "target_branch", null: false
t.integer "status", limit: 2, default: 0, null: false
+ t.datetime_with_timezone "merged_at"
+ t.integer "duration"
t.index ["merge_request_id"], name: "index_merge_trains_on_merge_request_id", unique: true
t.index ["pipeline_id"], name: "index_merge_trains_on_pipeline_id"
t.index ["target_project_id", "target_branch", "status"], name: "index_for_status_per_branch_per_project"
@@ -2777,8 +2808,10 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["commit_id"], name: "index_notes_on_commit_id"
t.index ["created_at"], name: "index_notes_on_created_at"
t.index ["discussion_id"], name: "index_notes_on_discussion_id"
+ t.index ["id"], name: "epic_mentions_temp_index", where: "((note ~~ '%@%'::text) AND ((noteable_type)::text = 'Epic'::text))"
t.index ["line_code"], name: "index_notes_on_line_code"
t.index ["note"], name: "index_notes_on_note_trigram", opclass: :gin_trgm_ops, using: :gin
+ t.index ["note"], name: "tmp_idx_on_promoted_notes", where: "(((noteable_type)::text = 'Issue'::text) AND (system IS TRUE) AND (note ~~ 'promoted to epic%'::text))"
t.index ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type"
t.index ["project_id", "id"], name: "index_notes_on_project_id_and_id_and_system_false", where: "(NOT system)"
t.index ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type"
@@ -2852,6 +2885,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "owner_id"
t.string "owner_type"
t.boolean "trusted", default: false, null: false
+ t.boolean "confidential", default: true, null: false
t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
end
@@ -2879,6 +2913,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime_with_timezone "updated_at", null: false
t.string "name", null: false
t.text "description"
+ t.integer "iid", null: false
+ t.index ["project_id", "iid"], name: "index_operations_feature_flags_on_project_id_and_iid", unique: true
t.index ["project_id", "name"], name: "index_operations_feature_flags_on_project_id_and_name", unique: true
end
@@ -2888,6 +2924,19 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["project_id", "token_encrypted"], name: "index_feature_flags_clients_on_project_id_and_token_encrypted", unique: true
end
+ create_table "operations_scopes", force: :cascade do |t|
+ t.bigint "strategy_id", null: false
+ t.string "environment_scope", limit: 255, null: false
+ t.index ["strategy_id", "environment_scope"], name: "index_operations_scopes_on_strategy_id_and_environment_scope", unique: true
+ end
+
+ create_table "operations_strategies", force: :cascade do |t|
+ t.bigint "feature_flag_id", null: false
+ t.string "name", limit: 255, null: false
+ t.jsonb "parameters", default: {}, null: false
+ t.index ["feature_flag_id"], name: "index_operations_strategies_on_feature_flag_id"
+ end
+
create_table "packages_build_infos", force: :cascade do |t|
t.integer "package_id", null: false
t.integer "pipeline_id"
@@ -2912,7 +2961,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime_with_timezone "updated_at", null: false
t.string "package_username", limit: 255, null: false
t.string "package_channel", limit: 255, null: false
- t.index ["package_id"], name: "index_packages_conan_metadata_on_package_id", unique: true
+ t.index ["package_id", "package_username", "package_channel"], name: "index_packages_conan_metadata_on_package_id_username_channel", unique: true
end
create_table "packages_dependencies", force: :cascade do |t|
@@ -2962,8 +3011,11 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "version"
t.integer "package_type", limit: 2, null: false
t.index ["name"], name: "index_packages_packages_on_name_trigram", opclass: :gin_trgm_ops, using: :gin
+ t.index ["project_id", "created_at"], name: "index_packages_packages_on_project_id_and_created_at"
t.index ["project_id", "name", "version", "package_type"], name: "idx_packages_packages_on_project_id_name_version_package_type"
- t.index ["project_id"], name: "index_packages_packages_on_project_id"
+ t.index ["project_id", "name"], name: "index_packages_project_id_name_partial_for_nuget", where: "(((name)::text <> 'NuGet.Temporary.Package'::text) AND (version IS NOT NULL) AND (package_type = 4))"
+ t.index ["project_id", "package_type"], name: "index_packages_packages_on_project_id_and_package_type"
+ t.index ["project_id", "version"], name: "index_packages_packages_on_project_id_and_version"
end
create_table "packages_tags", force: :cascade do |t|
@@ -3005,13 +3057,15 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime_with_timezone "certificate_valid_not_after"
t.integer "certificate_source", limit: 2, default: 0, null: false
t.boolean "wildcard", default: false, null: false
- t.integer "domain_type", limit: 2, default: 2, null: false
+ t.integer "usage", limit: 2, default: 0, null: false
+ t.integer "scope", limit: 2, default: 2, null: false
t.index ["certificate_source", "certificate_valid_not_after"], name: "index_pages_domains_need_auto_ssl_renewal", where: "(auto_ssl_enabled = true)"
- t.index ["domain"], name: "index_pages_domains_on_domain", unique: true
- t.index ["domain_type"], name: "index_pages_domains_on_domain_type"
+ t.index ["domain", "wildcard"], name: "index_pages_domains_on_domain_and_wildcard", unique: true
t.index ["project_id", "enabled_until"], name: "index_pages_domains_on_project_id_and_enabled_until"
t.index ["project_id"], name: "index_pages_domains_on_project_id"
t.index ["remove_at"], name: "index_pages_domains_on_remove_at"
+ t.index ["scope"], name: "index_pages_domains_on_scope"
+ t.index ["usage"], name: "index_pages_domains_on_usage"
t.index ["verified_at", "enabled_until"], name: "index_pages_domains_on_verified_at_and_enabled_until"
t.index ["verified_at"], name: "index_pages_domains_on_verified_at"
t.index ["wildcard"], name: "index_pages_domains_on_wildcard"
@@ -3114,6 +3168,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.boolean "group_runners_enabled", default: true, null: false
t.boolean "merge_pipelines_enabled"
t.integer "default_git_depth"
+ t.boolean "forward_deployment_enabled"
t.index ["project_id"], name: "index_project_ci_cd_settings_on_project_id", unique: true
end
@@ -3258,6 +3313,11 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["project_id"], name: "index_project_repository_states_on_project_id", unique: true
end
+ create_table "project_settings", primary_key: "project_id", id: :integer, default: nil, force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ end
+
create_table "project_statistics", id: :serial, force: :cascade do |t|
t.integer "project_id", null: false
t.integer "namespace_id", null: false
@@ -3367,7 +3427,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index "lower((name)::text)", name: "index_projects_on_lower_name"
t.index ["created_at", "id"], name: "index_projects_api_created_at_id_desc", order: { id: :desc }
t.index ["created_at", "id"], name: "index_projects_api_vis20_created_at", where: "(visibility_level = 20)"
- t.index ["created_at", "id"], name: "index_projects_api_vis20_created_at_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["created_at", "id"], name: "index_projects_on_created_at_and_id"
t.index ["creator_id"], name: "index_projects_on_creator_id"
t.index ["description"], name: "index_projects_on_description_trigram", opclass: :gin_trgm_ops, using: :gin
@@ -3377,7 +3436,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["id"], name: "index_projects_on_mirror_and_mirror_trigger_builds_both_true", where: "((mirror IS TRUE) AND (mirror_trigger_builds IS TRUE))"
t.index ["last_activity_at", "id"], name: "index_projects_api_last_activity_at_id_desc", order: { id: :desc }
t.index ["last_activity_at", "id"], name: "index_projects_api_vis20_last_activity_at", where: "(visibility_level = 20)"
- t.index ["last_activity_at", "id"], name: "index_projects_api_vis20_last_activity_at_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["last_activity_at", "id"], name: "index_projects_on_last_activity_at_and_id"
t.index ["last_repository_check_at"], name: "index_projects_on_last_repository_check_at", where: "(last_repository_check_at IS NOT NULL)"
t.index ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed"
@@ -3388,13 +3446,11 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["mirror_user_id"], name: "index_projects_on_mirror_user_id"
t.index ["name", "id"], name: "index_projects_api_name_id_desc", order: { id: :desc }
t.index ["name", "id"], name: "index_projects_api_vis20_name", where: "(visibility_level = 20)"
- t.index ["name", "id"], name: "index_projects_api_vis20_name_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["name", "id"], name: "index_projects_on_name_and_id"
t.index ["name"], name: "index_projects_on_name_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["namespace_id"], name: "index_projects_on_namespace_id"
t.index ["path", "id"], name: "index_projects_api_path_id_desc", order: { id: :desc }
t.index ["path", "id"], name: "index_projects_api_vis20_path", where: "(visibility_level = 20)"
- t.index ["path", "id"], name: "index_projects_api_vis20_path_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["path", "id"], name: "index_projects_on_path_and_id"
t.index ["path"], name: "index_projects_on_path_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["pending_delete"], name: "index_projects_on_pending_delete"
@@ -3406,7 +3462,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["star_count"], name: "index_projects_on_star_count"
t.index ["updated_at", "id"], name: "index_projects_api_updated_at_id_desc", order: { id: :desc }
t.index ["updated_at", "id"], name: "index_projects_api_vis20_updated_at", where: "(visibility_level = 20)"
- t.index ["updated_at", "id"], name: "index_projects_api_vis20_updated_at_id_desc", order: { id: :desc }, where: "(visibility_level = 20)"
t.index ["updated_at", "id"], name: "index_projects_on_updated_at_and_id"
end
@@ -3657,6 +3712,23 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["user_id"], name: "index_resource_label_events_on_user_id"
end
+ create_table "resource_milestone_events", force: :cascade do |t|
+ t.bigint "user_id", null: false
+ t.bigint "issue_id"
+ t.bigint "merge_request_id"
+ t.bigint "milestone_id"
+ t.integer "action", limit: 2, null: false
+ t.integer "state", limit: 2, null: false
+ t.integer "cached_markdown_version"
+ t.text "reference"
+ t.text "reference_html"
+ t.datetime_with_timezone "created_at", null: false
+ t.index ["issue_id"], name: "index_resource_milestone_events_on_issue_id"
+ t.index ["merge_request_id"], name: "index_resource_milestone_events_on_merge_request_id"
+ t.index ["milestone_id"], name: "index_resource_milestone_events_on_milestone_id"
+ t.index ["user_id"], name: "index_resource_milestone_events_on_user_id"
+ end
+
create_table "resource_weight_events", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "issue_id", null: false
@@ -3695,6 +3767,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "sso_url", null: false
t.boolean "enforced_sso", default: false, null: false
t.boolean "enforced_group_managed_accounts", default: false, null: false
+ t.boolean "prohibited_outer_forks", default: false
t.index ["group_id"], name: "index_saml_providers_on_group_id"
end
@@ -3706,6 +3779,15 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["group_id", "token_encrypted"], name: "index_scim_oauth_access_tokens_on_group_id_and_token_encrypted", unique: true
end
+ create_table "security_scans", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.bigint "build_id", null: false
+ t.integer "scan_type", limit: 2, null: false
+ t.index ["build_id", "scan_type"], name: "idx_security_scans_on_build_and_scan_type", unique: true
+ t.index ["scan_type"], name: "idx_security_scans_on_scan_type"
+ end
+
create_table "self_managed_prometheus_alert_events", force: :cascade do |t|
t.bigint "project_id", null: false
t.bigint "environment_id"
@@ -3746,6 +3828,9 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.bigint "creator_id"
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
+ t.text "encrypted_key"
+ t.string "encrypted_key_iv", limit: 255
+ t.text "certificate"
t.index ["clusters_applications_knative_id"], name: "idx_serverless_domain_cluster_on_clusters_applications_knative", unique: true
t.index ["creator_id"], name: "index_serverless_domain_cluster_on_creator_id"
t.index ["pages_domain_id"], name: "index_serverless_domain_cluster_on_pages_domain_id"
@@ -3754,6 +3839,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
create_table "service_desk_settings", primary_key: "project_id", id: :bigint, default: nil, force: :cascade do |t|
t.string "issue_template_key", limit: 255
t.string "outgoing_name", limit: 255
+ t.string "project_key", limit: 255
end
create_table "services", id: :serial, force: :cascade do |t|
@@ -3764,7 +3850,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime "updated_at"
t.boolean "active", default: false, null: false
t.text "properties"
- t.boolean "template", default: false
t.boolean "push_events", default: true
t.boolean "issues_events", default: true
t.boolean "merge_requests_events", default: true
@@ -3781,8 +3866,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.boolean "deployment_events", default: false, null: false
t.string "description", limit: 500
t.boolean "comment_on_event_enabled", default: true, null: false
+ t.boolean "template", default: false
t.index ["project_id"], name: "index_services_on_project_id"
- t.index ["project_id"], name: "tmp_index_on_project_id_partial_with_prometheus_services", where: "((type)::text = 'PrometheusService'::text)"
t.index ["template"], name: "index_services_on_template"
t.index ["type"], name: "index_services_on_type"
end
@@ -3812,6 +3897,13 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.index ["user_id"], name: "index_smartcard_identities_on_user_id"
end
+ create_table "snippet_repositories", primary_key: "snippet_id", id: :bigint, default: nil, force: :cascade do |t|
+ t.bigint "shard_id", null: false
+ t.string "disk_path", limit: 80, null: false
+ t.index ["disk_path"], name: "index_snippet_repositories_on_disk_path", unique: true
+ t.index ["shard_id"], name: "index_snippet_repositories_on_shard_id"
+ end
+
create_table "snippet_user_mentions", force: :cascade do |t|
t.integer "snippet_id", null: false
t.integer "note_id"
@@ -3842,7 +3934,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "encrypted_secret_token_iv", limit: 255
t.boolean "secret", default: false, null: false
t.string "repository_storage", limit: 255, default: "default", null: false
- t.integer "storage_version", default: 2, null: false
t.index ["author_id"], name: "index_snippets_on_author_id"
t.index ["content"], name: "index_snippets_on_content_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["created_at"], name: "index_snippets_on_created_at"
@@ -3857,8 +3948,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.integer "project_id", null: false
t.integer "software_license_id", null: false
t.integer "classification", default: 0, null: false
- t.datetime_with_timezone "created_at"
- t.datetime_with_timezone "updated_at"
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
t.index ["project_id", "software_license_id"], name: "index_software_license_policies_unique_per_project", unique: true
t.index ["software_license_id"], name: "index_software_license_policies_on_software_license_id"
end
@@ -4039,6 +4130,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
create_table "user_callouts", id: :serial, force: :cascade do |t|
t.integer "feature_name", null: false
t.integer "user_id", null: false
+ t.datetime_with_timezone "dismissed_at"
t.index ["user_id", "feature_name"], name: "index_user_callouts_on_user_id_and_feature_name", unique: true
t.index ["user_id"], name: "index_user_callouts_on_user_id"
end
@@ -4081,6 +4173,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.boolean "sourcegraph_enabled"
t.boolean "setup_for_company"
t.boolean "render_whitespace_in_code"
+ t.integer "tab_width", limit: 2
+ t.bigint "feature_filter_type"
t.index ["user_id"], name: "index_user_preferences_on_user_id", unique: true
end
@@ -4265,8 +4359,11 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.datetime_with_timezone "resolved_at"
t.integer "report_type", limit: 2, null: false
t.integer "cached_markdown_version"
+ t.bigint "confirmed_by_id"
+ t.datetime_with_timezone "confirmed_at"
t.index ["author_id"], name: "index_vulnerabilities_on_author_id"
t.index ["closed_by_id"], name: "index_vulnerabilities_on_closed_by_id"
+ t.index ["confirmed_by_id"], name: "index_vulnerabilities_on_confirmed_by_id"
t.index ["due_date_sourcing_milestone_id"], name: "index_vulnerabilities_on_due_date_sourcing_milestone_id"
t.index ["epic_id"], name: "index_vulnerabilities_on_epic_id"
t.index ["last_edited_by_id"], name: "index_vulnerabilities_on_last_edited_by_id"
@@ -4413,10 +4510,45 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
t.string "encrypted_token_iv"
t.string "encrypted_url"
t.string "encrypted_url_iv"
+ t.index ["group_id"], name: "index_web_hooks_on_group_id", where: "((type)::text = 'GroupHook'::text)"
t.index ["project_id"], name: "index_web_hooks_on_project_id"
t.index ["type"], name: "index_web_hooks_on_type"
end
+ create_table "x509_certificates", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.string "subject_key_identifier", limit: 255, null: false
+ t.string "subject", limit: 255, null: false
+ t.string "email", limit: 255, null: false
+ t.binary "serial_number", null: false
+ t.integer "certificate_status", limit: 2, default: 0, null: false
+ t.bigint "x509_issuer_id", null: false
+ t.index ["subject_key_identifier"], name: "index_x509_certificates_on_subject_key_identifier"
+ t.index ["x509_issuer_id"], name: "index_x509_certificates_on_x509_issuer_id"
+ end
+
+ create_table "x509_commit_signatures", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.bigint "project_id", null: false
+ t.bigint "x509_certificate_id", null: false
+ t.binary "commit_sha", null: false
+ t.integer "verification_status", limit: 2, default: 0, null: false
+ t.index ["commit_sha"], name: "index_x509_commit_signatures_on_commit_sha"
+ t.index ["project_id"], name: "index_x509_commit_signatures_on_project_id"
+ t.index ["x509_certificate_id"], name: "index_x509_commit_signatures_on_x509_certificate_id"
+ end
+
+ create_table "x509_issuers", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.string "subject_key_identifier", limit: 255, null: false
+ t.string "subject", limit: 255, null: false
+ t.string "crl_url", limit: 255, null: false
+ t.index ["subject_key_identifier"], name: "index_x509_issuers_on_subject_key_identifier"
+ end
+
create_table "zoom_meetings", force: :cascade do |t|
t.bigint "project_id", null: false
t.bigint "issue_id", null: false
@@ -4440,11 +4572,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "analytics_cycle_analytics_project_stages", "projects", on_delete: :cascade
add_foreign_key "analytics_language_trend_repository_languages", "programming_languages", on_delete: :cascade
add_foreign_key "analytics_language_trend_repository_languages", "projects", on_delete: :cascade
- add_foreign_key "analytics_repository_file_commits", "analytics_repository_files", on_delete: :cascade
- add_foreign_key "analytics_repository_file_commits", "projects", on_delete: :cascade
- add_foreign_key "analytics_repository_file_edits", "analytics_repository_files", on_delete: :cascade
- add_foreign_key "analytics_repository_file_edits", "projects", on_delete: :cascade
- add_foreign_key "analytics_repository_files", "projects", on_delete: :cascade
add_foreign_key "application_settings", "namespaces", column: "custom_project_templates_group_id", on_delete: :nullify
add_foreign_key "application_settings", "namespaces", column: "instance_administrators_group_id", name: "fk_e8a145f3a7", on_delete: :nullify
add_foreign_key "application_settings", "projects", column: "file_template_project_id", name: "fk_ec757bd087", on_delete: :nullify
@@ -4565,6 +4692,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "dependency_proxy_blobs", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "dependency_proxy_group_settings", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "deploy_keys_projects", "projects", name: "fk_58a901ca7e", on_delete: :cascade
+ add_foreign_key "deployment_clusters", "clusters", on_delete: :cascade
+ add_foreign_key "deployment_clusters", "deployments", on_delete: :cascade
add_foreign_key "deployment_merge_requests", "deployments", on_delete: :cascade
add_foreign_key "deployment_merge_requests", "merge_requests", on_delete: :cascade
add_foreign_key "deployments", "clusters", name: "fk_289bba3222", on_delete: :nullify
@@ -4612,6 +4741,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "geo_container_repository_updated_events", "container_repositories", name: "fk_212c89c706", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_cache_invalidation_events", column: "cache_invalidation_event_id", name: "fk_42c3b54bed", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_container_repository_updated_events", column: "container_repository_updated_event_id", name: "fk_6ada82d42a", on_delete: :cascade
+ add_foreign_key "geo_event_log", "geo_events", name: "fk_geo_event_log_on_geo_event_id", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_hashed_storage_migrated_events", column: "hashed_storage_migrated_event_id", name: "fk_27548c6db3", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_job_artifact_deleted_events", column: "job_artifact_deleted_event_id", name: "fk_176d3fbb5d", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_lfs_object_deleted_events", column: "lfs_object_deleted_event_id", name: "fk_d5af95fcd9", on_delete: :cascade
@@ -4643,6 +4773,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "group_custom_attributes", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "group_deletion_schedules", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "group_deletion_schedules", "users", name: "fk_11e3ebfcdd", on_delete: :cascade
+ add_foreign_key "group_deploy_tokens", "deploy_tokens", on_delete: :cascade
+ add_foreign_key "group_deploy_tokens", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "group_group_links", "namespaces", column: "shared_group_id", on_delete: :cascade
add_foreign_key "group_group_links", "namespaces", column: "shared_with_group_id", on_delete: :cascade
add_foreign_key "identities", "saml_providers", name: "fk_aade90f0fc", on_delete: :cascade
@@ -4660,8 +4792,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "issue_links", "issues", column: "source_id", name: "fk_c900194ff2", on_delete: :cascade
add_foreign_key "issue_links", "issues", column: "target_id", name: "fk_e71bb44f1f", on_delete: :cascade
add_foreign_key "issue_metrics", "issues", on_delete: :cascade
- add_foreign_key "issue_milestones", "issues", on_delete: :cascade
- add_foreign_key "issue_milestones", "milestones", on_delete: :cascade
add_foreign_key "issue_tracker_data", "services", on_delete: :cascade
add_foreign_key "issue_user_mentions", "issues", on_delete: :cascade
add_foreign_key "issue_user_mentions", "notes", on_delete: :cascade
@@ -4698,6 +4828,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "merge_request_assignees", "users", on_delete: :cascade
add_foreign_key "merge_request_blocks", "merge_requests", column: "blocked_merge_request_id", on_delete: :cascade
add_foreign_key "merge_request_blocks", "merge_requests", column: "blocking_merge_request_id", on_delete: :cascade
+ add_foreign_key "merge_request_context_commit_diff_files", "merge_request_context_commits", on_delete: :cascade
+ add_foreign_key "merge_request_context_commits", "merge_requests", on_delete: :cascade
add_foreign_key "merge_request_diff_commits", "merge_request_diffs", on_delete: :cascade
add_foreign_key "merge_request_diff_files", "merge_request_diffs", on_delete: :cascade
add_foreign_key "merge_request_diffs", "merge_requests", name: "fk_8483f3258f", on_delete: :cascade
@@ -4705,8 +4837,6 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "merge_request_metrics", "merge_requests", on_delete: :cascade
add_foreign_key "merge_request_metrics", "users", column: "latest_closed_by_id", name: "fk_ae440388cc", on_delete: :nullify
add_foreign_key "merge_request_metrics", "users", column: "merged_by_id", name: "fk_7f28d925f3", on_delete: :nullify
- add_foreign_key "merge_request_milestones", "merge_requests", on_delete: :cascade
- add_foreign_key "merge_request_milestones", "milestones", on_delete: :cascade
add_foreign_key "merge_request_user_mentions", "merge_requests", on_delete: :cascade
add_foreign_key "merge_request_user_mentions", "notes", on_delete: :cascade
add_foreign_key "merge_requests", "ci_pipelines", column: "head_pipeline_id", name: "fk_fd82eae0b9", on_delete: :nullify
@@ -4742,6 +4872,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "operations_feature_flag_scopes", "operations_feature_flags", column: "feature_flag_id", on_delete: :cascade
add_foreign_key "operations_feature_flags", "projects", on_delete: :cascade
add_foreign_key "operations_feature_flags_clients", "projects", on_delete: :cascade
+ add_foreign_key "operations_scopes", "operations_strategies", column: "strategy_id", on_delete: :cascade
+ add_foreign_key "operations_strategies", "operations_feature_flags", column: "feature_flag_id", on_delete: :cascade
add_foreign_key "packages_build_infos", "ci_pipelines", column: "pipeline_id", on_delete: :nullify
add_foreign_key "packages_build_infos", "packages_packages", column: "package_id", on_delete: :cascade
add_foreign_key "packages_conan_file_metadata", "packages_package_files", column: "package_file_id", on_delete: :cascade
@@ -4782,6 +4914,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "project_repositories", "projects", on_delete: :cascade
add_foreign_key "project_repositories", "shards", on_delete: :restrict
add_foreign_key "project_repository_states", "projects", on_delete: :cascade
+ add_foreign_key "project_settings", "projects", on_delete: :cascade
add_foreign_key "project_statistics", "projects", on_delete: :cascade
add_foreign_key "project_tracing_settings", "projects", on_delete: :cascade
add_foreign_key "projects", "pool_repositories", name: "fk_6e5c14658a", on_delete: :nullify
@@ -4822,6 +4955,10 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "resource_label_events", "labels", on_delete: :nullify
add_foreign_key "resource_label_events", "merge_requests", on_delete: :cascade
add_foreign_key "resource_label_events", "users", on_delete: :nullify
+ add_foreign_key "resource_milestone_events", "issues", on_delete: :cascade
+ add_foreign_key "resource_milestone_events", "merge_requests", on_delete: :cascade
+ add_foreign_key "resource_milestone_events", "milestones", on_delete: :cascade
+ add_foreign_key "resource_milestone_events", "users", on_delete: :nullify
add_foreign_key "resource_weight_events", "issues", on_delete: :cascade
add_foreign_key "resource_weight_events", "users", on_delete: :nullify
add_foreign_key "reviews", "merge_requests", on_delete: :cascade
@@ -4829,6 +4966,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "reviews", "users", column: "author_id", on_delete: :nullify
add_foreign_key "saml_providers", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "scim_oauth_access_tokens", "namespaces", column: "group_id", on_delete: :cascade
+ add_foreign_key "security_scans", "ci_builds", column: "build_id", on_delete: :cascade
add_foreign_key "self_managed_prometheus_alert_events", "environments", on_delete: :cascade
add_foreign_key "self_managed_prometheus_alert_events", "projects", on_delete: :cascade
add_foreign_key "sentry_issues", "issues", on_delete: :cascade
@@ -4839,6 +4977,8 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "services", "projects", name: "fk_71cce407f9", on_delete: :cascade
add_foreign_key "slack_integrations", "services", on_delete: :cascade
add_foreign_key "smartcard_identities", "users", on_delete: :cascade
+ add_foreign_key "snippet_repositories", "shards", on_delete: :restrict
+ add_foreign_key "snippet_repositories", "snippets", on_delete: :cascade
add_foreign_key "snippet_user_mentions", "notes", on_delete: :cascade
add_foreign_key "snippet_user_mentions", "snippets", on_delete: :cascade
add_foreign_key "snippets", "projects", name: "fk_be41fd4bb7", on_delete: :cascade
@@ -4880,6 +5020,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "vulnerabilities", "projects", name: "fk_efb96ab1e2", on_delete: :cascade
add_foreign_key "vulnerabilities", "users", column: "author_id", name: "fk_b1de915a15", on_delete: :nullify
add_foreign_key "vulnerabilities", "users", column: "closed_by_id", name: "fk_cf5c60acbf", on_delete: :nullify
+ add_foreign_key "vulnerabilities", "users", column: "confirmed_by_id", name: "fk_959d40ad0a", on_delete: :nullify
add_foreign_key "vulnerabilities", "users", column: "last_edited_by_id", name: "fk_1302949740", on_delete: :nullify
add_foreign_key "vulnerabilities", "users", column: "resolved_by_id", name: "fk_76bc5f5455", on_delete: :nullify
add_foreign_key "vulnerabilities", "users", column: "updated_by_id", name: "fk_7ac31eacb9", on_delete: :nullify
@@ -4903,6 +5044,9 @@ ActiveRecord::Schema.define(version: 2020_02_04_113223) do
add_foreign_key "vulnerability_scanners", "projects", on_delete: :cascade
add_foreign_key "web_hook_logs", "web_hooks", on_delete: :cascade
add_foreign_key "web_hooks", "projects", name: "fk_0c8ca6d9d1", on_delete: :cascade
+ add_foreign_key "x509_certificates", "x509_issuers", on_delete: :cascade
+ add_foreign_key "x509_commit_signatures", "projects", on_delete: :cascade
+ add_foreign_key "x509_commit_signatures", "x509_certificates", on_delete: :cascade
add_foreign_key "zoom_meetings", "issues", on_delete: :cascade
add_foreign_key "zoom_meetings", "projects", on_delete: :cascade
end