summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-19 22:11:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-19 22:11:55 +0000
commit5a8431feceba47fd8e1804d9aa1b1730606b71d5 (patch)
treee5df8e0ceee60f4af8093f5c4c2f934b8abced05 /db
parent4d477238500c347c6553d335d920bedfc5a46869 (diff)
downloadgitlab-ce-5a8431feceba47fd8e1804d9aa1b1730606b71d5.tar.gz
Add latest changes from gitlab-org/gitlab@12-5-stable-ee
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/02_users.rb77
-rw-r--r--db/fixtures/development/03_project.rb297
-rw-r--r--db/fixtures/development/04_labels.rb2
-rw-r--r--db/fixtures/development/05_users.rb34
-rw-r--r--db/fixtures/development/06_teams.rb6
-rw-r--r--db/fixtures/development/07_milestones.rb2
-rw-r--r--db/fixtures/development/10_merge_requests.rb8
-rw-r--r--db/fixtures/development/11_keys.rb2
-rw-r--r--db/fixtures/development/12_snippets.rb2
-rw-r--r--db/fixtures/development/14_pipelines.rb2
-rw-r--r--db/fixtures/development/16_protected_branches.rb2
-rw-r--r--db/fixtures/development/17_cycle_analytics.rb2
-rw-r--r--db/fixtures/development/19_environments.rb2
-rw-r--r--db/fixtures/development/23_spam_logs.rb2
-rw-r--r--db/fixtures/development/24_forks.rb4
-rw-r--r--db/migrate/20180215181245_users_name_lower_index.rb6
-rw-r--r--db/migrate/20180504195842_project_name_lower_index.rb6
-rw-r--r--db/migrate/20180902070406_create_group_group_links.rb32
-rw-r--r--db/migrate/20190703171157_add_sourcing_epic_dates.rb10
-rw-r--r--db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb25
-rw-r--r--db/migrate/20190805140353_remove_rendundant_index_from_releases.rb7
-rw-r--r--db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb21
-rw-r--r--db/migrate/20190910211526_create_packages_conan_file_metadata.rb18
-rw-r--r--db/migrate/20190918104731_add_cleanup_status_to_cluster.rb21
-rw-r--r--db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb12
-rw-r--r--db/migrate/20190930153535_create_zoom_meetings.rb24
-rw-r--r--db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb22
-rw-r--r--db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb1
-rw-r--r--db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb11
-rw-r--r--db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb19
-rw-r--r--db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb15
-rw-r--r--db/migrate/20191003195620_add_pendo_url_to_application_settings.rb9
-rw-r--r--db/migrate/20191004080818_add_productivity_analytics_start_date.rb11
-rw-r--r--db/migrate/20191004081520_fill_productivity_analytics_start_date.rb31
-rw-r--r--db/migrate/20191009100244_add_geo_design_repository_counters.rb16
-rw-r--r--db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb13
-rw-r--r--db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb17
-rw-r--r--db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb9
-rw-r--r--db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb11
-rw-r--r--db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb9
-rw-r--r--db/migrate/20191014025629_rename_design_management_version_user_to_author.rb17
-rw-r--r--db/migrate/20191014030730_add_author_index_to_design_management_versions.rb17
-rw-r--r--db/migrate/20191016133352_create_ci_subscriptions_projects.rb21
-rw-r--r--db/migrate/20191017001326_create_users_security_dashboard_projects.rb15
-rw-r--r--db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb17
-rw-r--r--db/migrate/20191017134513_add_deployment_merge_requests.rb33
-rw-r--r--db/migrate/20191017191341_create_clusters_applications_crossplane.rb19
-rw-r--r--db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb19
-rw-r--r--db/migrate/20191023152913_add_default_and_free_plans.rb29
-rw-r--r--db/migrate/20191024134020_add_index_to_zoom_meetings.rb17
-rw-r--r--db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb15
-rw-r--r--db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb9
-rw-r--r--db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb17
-rw-r--r--db/migrate/20191029125305_create_packages_conan_metadata.rb16
-rw-r--r--db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb23
-rw-r--r--db/migrate/20191030135044_create_plan_limits.rb14
-rw-r--r--db/migrate/20191030152934_move_limits_from_plans.rb17
-rw-r--r--db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb19
-rw-r--r--db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb14
-rw-r--r--db/migrate/20191104205020_add_license_details_to_application_settings.rb11
-rw-r--r--db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb9
-rw-r--r--db/migrate/20191105193652_add_index_on_deployments_updated_at.rb18
-rw-r--r--db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb17
-rw-r--r--db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb17
-rw-r--r--db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb9
-rw-r--r--db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb19
-rw-r--r--db/migrate/20191111121500_default_ci_config_path.rb13
-rw-r--r--db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb9
-rw-r--r--db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb19
-rw-r--r--db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb19
-rw-r--r--db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb18
-rw-r--r--db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb15
-rw-r--r--db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb19
-rw-r--r--db/migrate/20191115091425_create_vulnerability_issue_links.rb23
-rw-r--r--db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb68
-rw-r--r--db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb2
-rw-r--r--db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb35
-rw-r--r--db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb51
-rw-r--r--db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb17
-rw-r--r--db/post_migrate/20191017045817_schedule_fix_gitlab_com_pages_access_level.rb17
-rw-r--r--db/post_migrate/20191017180026_drop_ci_build_trace_sections_id.rb19
-rw-r--r--db/post_migrate/20191021101942_remove_empty_github_service_templates.rb28
-rw-r--r--db/post_migrate/20191022113635_nullify_feature_flag_plaintext_tokens.rb39
-rw-r--r--db/post_migrate/20191029095537_cleanup_application_settings_snowplow_site_id_rename.rb17
-rw-r--r--db/post_migrate/20191030193050_remove_pendo_from_application_settings.rb19
-rw-r--r--db/post_migrate/20191031112603_remove_limits_from_plans.rb17
-rw-r--r--db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb26
-rw-r--r--db/post_migrate/20191105140942_add_indices_to_abuse_reports.rb17
-rw-r--r--db/post_migrate/20191112115317_change_vulnerabilities_title_html_to_nullable.rb9
-rw-r--r--db/post_migrate/20191114173624_set_resolved_state_on_vulnerabilities.rb31
-rw-r--r--db/schema.rb199
91 files changed, 1763 insertions, 251 deletions
diff --git a/db/fixtures/development/02_users.rb b/db/fixtures/development/02_users.rb
new file mode 100644
index 00000000000..6e0b37d7258
--- /dev/null
+++ b/db/fixtures/development/02_users.rb
@@ -0,0 +1,77 @@
+# frozen_string_literal: true
+
+class Gitlab::Seeder::Users
+ include ActionView::Helpers::NumberHelper
+
+ RANDOM_USERS_COUNT = 20
+ MASS_USERS_COUNT = ENV['CI'] ? 10 : 1_000_000
+ MASS_INSERT_USERNAME_START = 'mass_insert_user_'
+
+ attr_reader :opts
+
+ def initialize(opts = {})
+ @opts = opts
+ end
+
+ def seed!
+ Sidekiq::Testing.inline! do
+ create_mass_users!
+ create_random_users!
+ end
+ end
+
+ private
+
+ def create_mass_users!
+ encrypted_password = Devise::Encryptor.digest(User, '12345678')
+
+ Gitlab::Seeder.with_mass_insert(MASS_USERS_COUNT, User) do
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO users (username, name, email, confirmed_at, projects_limit, encrypted_password)
+ SELECT
+ '#{MASS_INSERT_USERNAME_START}' || seq,
+ 'Seed user ' || seq,
+ 'seed_user' || seq || '@example.com',
+ to_timestamp(seq),
+ #{MASS_USERS_COUNT},
+ '#{encrypted_password}'
+ FROM generate_series(1, #{MASS_USERS_COUNT}) AS seq
+ SQL
+ end
+
+ relation = User.where(admin: false)
+ Gitlab::Seeder.with_mass_insert(relation.count, Namespace) do
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO namespaces (name, path, owner_id)
+ SELECT
+ username,
+ username,
+ id
+ FROM users WHERE NOT admin
+ SQL
+ end
+ end
+
+ def create_random_users!
+ RANDOM_USERS_COUNT.times do |i|
+ begin
+ User.create!(
+ username: FFaker::Internet.user_name,
+ name: FFaker::Name.name,
+ email: FFaker::Internet.email,
+ confirmed_at: DateTime.now,
+ password: '12345678'
+ )
+
+ print '.'
+ rescue ActiveRecord::RecordInvalid
+ print 'F'
+ end
+ end
+ end
+end
+
+Gitlab::Seeder.quiet do
+ users = Gitlab::Seeder::Users.new
+ users.seed!
+end
diff --git a/db/fixtures/development/03_project.rb b/db/fixtures/development/03_project.rb
index 46018cf68aa..87ef65276eb 100644
--- a/db/fixtures/development/03_project.rb
+++ b/db/fixtures/development/03_project.rb
@@ -1,137 +1,210 @@
require './spec/support/sidekiq'
-# rubocop:disable Rails/Output
-
-Sidekiq::Testing.inline! do
- Gitlab::Seeder.quiet do
- Gitlab::Seeder.without_gitaly_timeout do
- project_urls = %w[
- https://gitlab.com/gitlab-org/gitlab-test.git
- https://gitlab.com/gitlab-org/gitlab-shell.git
- https://gitlab.com/gnuwget/wget2.git
- https://gitlab.com/Commit451/LabCoat.git
- https://github.com/jashkenas/underscore.git
- https://github.com/flightjs/flight.git
- https://github.com/twitter/typeahead.js.git
- https://github.com/h5bp/html5-boilerplate.git
- https://github.com/google/material-design-lite.git
- https://github.com/jlevy/the-art-of-command-line.git
- https://github.com/FreeCodeCamp/freecodecamp.git
- https://github.com/google/deepdream.git
- https://github.com/jtleek/datasharing.git
- https://github.com/WebAssembly/design.git
- https://github.com/airbnb/javascript.git
- https://github.com/tessalt/echo-chamber-js.git
- https://github.com/atom/atom.git
- https://github.com/mattermost/mattermost-server.git
- https://github.com/purifycss/purifycss.git
- https://github.com/facebook/nuclide.git
- https://github.com/wbkd/awesome-d3.git
- https://github.com/kilimchoi/engineering-blogs.git
- https://github.com/gilbarbara/logos.git
- https://github.com/reduxjs/redux.git
- https://github.com/awslabs/s2n.git
- https://github.com/arkency/reactjs_koans.git
- https://github.com/twbs/bootstrap.git
- https://github.com/chjj/ttystudio.git
- https://github.com/MostlyAdequate/mostly-adequate-guide.git
- https://github.com/octocat/Spoon-Knife.git
- https://github.com/opencontainers/runc.git
- https://github.com/googlesamples/android-topeka.git
- ]
-
- large_project_urls = %w[
- https://github.com/torvalds/linux.git
- https://gitlab.gnome.org/GNOME/gimp.git
- https://gitlab.gnome.org/GNOME/gnome-mud.git
- https://gitlab.com/fdroid/fdroidclient.git
- https://gitlab.com/inkscape/inkscape.git
- https://github.com/gnachman/iTerm2.git
- ]
-
- def create_project(url, force_latest_storage: false)
- group_path, project_path = url.split('/')[-2..-1]
-
- group = Group.find_by(path: group_path)
-
- unless group
- group = Group.new(
- name: group_path.titleize,
- path: group_path
- )
- group.description = FFaker::Lorem.sentence
- group.save!
-
- group.add_owner(User.first)
- end
+class Gitlab::Seeder::Projects
+ include ActionView::Helpers::NumberHelper
+
+ PROJECT_URLS = %w[
+ https://gitlab.com/gitlab-org/gitlab-test.git
+ https://gitlab.com/gitlab-org/gitlab-shell.git
+ https://gitlab.com/gnuwget/wget2.git
+ https://gitlab.com/Commit451/LabCoat.git
+ https://github.com/jashkenas/underscore.git
+ https://github.com/flightjs/flight.git
+ https://github.com/twitter/typeahead.js.git
+ https://github.com/h5bp/html5-boilerplate.git
+ https://github.com/google/material-design-lite.git
+ https://github.com/jlevy/the-art-of-command-line.git
+ https://github.com/FreeCodeCamp/freecodecamp.git
+ https://github.com/google/deepdream.git
+ https://github.com/jtleek/datasharing.git
+ https://github.com/WebAssembly/design.git
+ https://github.com/airbnb/javascript.git
+ https://github.com/tessalt/echo-chamber-js.git
+ https://github.com/atom/atom.git
+ https://github.com/mattermost/mattermost-server.git
+ https://github.com/purifycss/purifycss.git
+ https://github.com/facebook/nuclide.git
+ https://github.com/wbkd/awesome-d3.git
+ https://github.com/kilimchoi/engineering-blogs.git
+ https://github.com/gilbarbara/logos.git
+ https://github.com/reduxjs/redux.git
+ https://github.com/awslabs/s2n.git
+ https://github.com/arkency/reactjs_koans.git
+ https://github.com/twbs/bootstrap.git
+ https://github.com/chjj/ttystudio.git
+ https://github.com/MostlyAdequate/mostly-adequate-guide.git
+ https://github.com/octocat/Spoon-Knife.git
+ https://github.com/opencontainers/runc.git
+ https://github.com/googlesamples/android-topeka.git
+ ]
+ LARGE_PROJECT_URLS = %w[
+ https://github.com/torvalds/linux.git
+ https://gitlab.gnome.org/GNOME/gimp.git
+ https://gitlab.gnome.org/GNOME/gnome-mud.git
+ https://gitlab.com/fdroid/fdroidclient.git
+ https://gitlab.com/inkscape/inkscape.git
+ https://github.com/gnachman/iTerm2.git
+ ]
+ # Consider altering MASS_USERS_COUNT for less
+ # users with projects.
+ MASS_PROJECTS_COUNT_PER_USER = {
+ private: 3, # 3m projects +
+ internal: 1, # 1m projects +
+ public: 1 # 1m projects = 5m total
+ }
+ MASS_INSERT_NAME_START = 'mass_insert_project_'
+
+ def seed!
+ Sidekiq::Testing.inline! do
+ create_real_projects!
+ create_large_projects!
+ create_mass_projects!
+ end
+ end
- project_path.gsub!(".git", "")
+ private
- params = {
- import_url: url,
- namespace_id: group.id,
- name: project_path.titleize,
- description: FFaker::Lorem.sentence,
- visibility_level: Gitlab::VisibilityLevel.values.sample,
- skip_disk_validation: true
- }
+ def create_real_projects!
+ # You can specify how many projects you need during seed execution
+ size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8
- if force_latest_storage
- params[:storage_version] = Project::LATEST_STORAGE_VERSION
- end
+ PROJECT_URLS.first(size).each_with_index do |url, i|
+ create_real_project!(url, force_latest_storage: i.even?)
+ end
+ end
- project = nil
+ def create_large_projects!
+ return unless ENV['LARGE_PROJECTS'].present?
- Sidekiq::Worker.skipping_transaction_check do
- project = Projects::CreateService.new(User.first, params).execute
+ LARGE_PROJECT_URLS.each(&method(:create_real_project!))
- # Seed-Fu runs this entire fixture in a transaction, so the `after_commit`
- # hook won't run until after the fixture is loaded. That is too late
- # since the Sidekiq::Testing block has already exited. Force clearing
- # the `after_commit` queue to ensure the job is run now.
- project.send(:_run_after_commit_queue)
- project.import_state.send(:_run_after_commit_queue)
- end
+ if ENV['FORK'].present?
+ puts "\nGenerating forks"
- if project.valid? && project.valid_repo?
+ project_name = ENV['FORK'] == 'true' ? 'torvalds/linux' : ENV['FORK']
+
+ project = Project.find_by_full_path(project_name)
+
+ User.offset(1).first(5).each do |user|
+ new_project = ::Projects::ForkService.new(project, user).execute
+
+ if new_project.valid? && (new_project.valid_repo? || new_project.import_state.scheduled?)
print '.'
else
- puts project.errors.full_messages
+ new_project.errors.full_messages.each do |error|
+ puts "#{new_project.full_path}: #{error}"
+ end
print 'F'
end
end
+ end
+ end
- # You can specify how many projects you need during seed execution
- size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8
+ def create_real_project!(url, force_latest_storage: false)
+ group_path, project_path = url.split('/')[-2..-1]
- project_urls.first(size).each_with_index do |url, i|
- create_project(url, force_latest_storage: i.even?)
- end
+ group = Group.find_by(path: group_path)
- if ENV['LARGE_PROJECTS'].present?
- large_project_urls.each(&method(:create_project))
+ unless group
+ group = Group.new(
+ name: group_path.titleize,
+ path: group_path
+ )
+ group.description = FFaker::Lorem.sentence
+ group.save!
- if ENV['FORK'].present?
- puts "\nGenerating forks"
+ group.add_owner(User.first)
+ end
- project_name = ENV['FORK'] == 'true' ? 'torvalds/linux' : ENV['FORK']
+ project_path.gsub!(".git", "")
- project = Project.find_by_full_path(project_name)
+ params = {
+ import_url: url,
+ namespace_id: group.id,
+ name: project_path.titleize,
+ description: FFaker::Lorem.sentence,
+ visibility_level: Gitlab::VisibilityLevel.values.sample,
+ skip_disk_validation: true
+ }
- User.offset(1).first(5).each do |user|
- new_project = Projects::ForkService.new(project, user).execute
+ if force_latest_storage
+ params[:storage_version] = Project::LATEST_STORAGE_VERSION
+ end
- if new_project.valid? && (new_project.valid_repo? || new_project.import_state.scheduled?)
- print '.'
- else
- new_project.errors.full_messages.each do |error|
- puts "#{new_project.full_path}: #{error}"
- end
- print 'F'
- end
- end
- end
- end
+ project = nil
+
+ Sidekiq::Worker.skipping_transaction_check do
+ project = ::Projects::CreateService.new(User.first, params).execute
+
+ # Seed-Fu runs this entire fixture in a transaction, so the `after_commit`
+ # hook won't run until after the fixture is loaded. That is too late
+ # since the Sidekiq::Testing block has already exited. Force clearing
+ # the `after_commit` queue to ensure the job is run now.
+ project.send(:_run_after_commit_queue)
+ project.import_state.send(:_run_after_commit_queue)
+ end
+
+ if project.valid? && project.valid_repo?
+ print '.'
+ else
+ puts project.errors.full_messages
+ print 'F'
end
end
+
+ def create_mass_projects!
+ projects_per_user_count = MASS_PROJECTS_COUNT_PER_USER.values.sum
+ visibility_per_user = ['private'] * MASS_PROJECTS_COUNT_PER_USER.fetch(:private) +
+ ['internal'] * MASS_PROJECTS_COUNT_PER_USER.fetch(:internal) +
+ ['public'] * MASS_PROJECTS_COUNT_PER_USER.fetch(:public)
+ visibility_level_per_user = visibility_per_user.map { |visibility| Gitlab::VisibilityLevel.level_value(visibility) }
+
+ visibility_per_user = visibility_per_user.join(',')
+ visibility_level_per_user = visibility_level_per_user.join(',')
+
+ Gitlab::Seeder.with_mass_insert(User.count * projects_per_user_count, "Projects and relations") do
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO projects (name, path, creator_id, namespace_id, visibility_level, created_at, updated_at)
+ SELECT
+ 'Seed project ' || seq || ' ' || ('{#{visibility_per_user}}'::text[])[seq] AS project_name,
+ 'mass_insert_project_' || ('{#{visibility_per_user}}'::text[])[seq] || '_' || seq AS project_path,
+ u.id AS user_id,
+ n.id AS namespace_id,
+ ('{#{visibility_level_per_user}}'::int[])[seq] AS visibility_level,
+ NOW() AS created_at,
+ NOW() AS updated_at
+ FROM users u
+ CROSS JOIN generate_series(1, #{projects_per_user_count}) AS seq
+ JOIN namespaces n ON n.owner_id=u.id
+ SQL
+
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO project_features (project_id, merge_requests_access_level, issues_access_level, wiki_access_level,
+ pages_access_level)
+ SELECT
+ id,
+ #{ProjectFeature::ENABLED} AS merge_requests_access_level,
+ #{ProjectFeature::ENABLED} AS issues_access_level,
+ #{ProjectFeature::ENABLED} AS wiki_access_level,
+ #{ProjectFeature::ENABLED} AS pages_access_level
+ FROM projects ON CONFLICT (project_id) DO NOTHING;
+ SQL
+
+ ActiveRecord::Base.connection.execute <<~SQL
+ INSERT INTO routes (source_id, source_type, name, path)
+ SELECT
+ p.id,
+ 'Project',
+ u.name || ' / ' || p.name,
+ u.username || '/' || p.path
+ FROM projects p JOIN users u ON u.id=p.creator_id
+ ON CONFLICT (source_type, source_id) DO NOTHING;
+ SQL
+ end
+ end
+end
+
+Gitlab::Seeder.quiet do
+ projects = Gitlab::Seeder::Projects.new
+ projects.seed!
end
diff --git a/db/fixtures/development/04_labels.rb b/db/fixtures/development/04_labels.rb
index b9ae4098d76..21d552c89f5 100644
--- a/db/fixtures/development/04_labels.rb
+++ b/db/fixtures/development/04_labels.rb
@@ -43,7 +43,7 @@ Gitlab::Seeder.quiet do
end
puts "\nGenerating project labels"
- Project.all.find_each do |project|
+ Project.not_mass_generated.find_each do |project|
Gitlab::Seeder::ProjectLabels.new(project).seed!
end
end
diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb
deleted file mode 100644
index 101ff3a1209..00000000000
--- a/db/fixtures/development/05_users.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require './spec/support/sidekiq'
-
-Gitlab::Seeder.quiet do
- 20.times do |i|
- begin
- User.create!(
- username: FFaker::Internet.user_name,
- name: FFaker::Name.name,
- email: FFaker::Internet.email,
- confirmed_at: DateTime.now,
- password: '12345678'
- )
-
- print '.'
- rescue ActiveRecord::RecordInvalid
- print 'F'
- end
- end
-
- 5.times do |i|
- begin
- User.create!(
- username: "user#{i}",
- name: "User #{i}",
- email: "user#{i}@example.com",
- confirmed_at: DateTime.now,
- password: '12345678'
- )
- print '.'
- rescue ActiveRecord::RecordInvalid
- print 'F'
- end
- end
-end
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index b218f4e71fd..79ea96bf30e 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -3,7 +3,7 @@ require './spec/support/sidekiq'
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
Group.all.each do |group|
- User.all.sample(4).each do |user|
+ User.not_mass_generated.sample(4).each do |user|
if group.add_user(user, Gitlab::Access.values.sample).persisted?
print '.'
else
@@ -12,8 +12,8 @@ Sidekiq::Testing.inline! do
end
end
- Project.all.each do |project|
- User.all.sample(4).each do |user|
+ Project.not_mass_generated.each do |project|
+ User.not_mass_generated.sample(4).each do |user|
if project.add_role(user, Gitlab::Access.sym_options.keys.sample)
print '.'
else
diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/07_milestones.rb
index 271bfbc97e0..1194bb3fe6f 100644
--- a/db/fixtures/development/07_milestones.rb
+++ b/db/fixtures/development/07_milestones.rb
@@ -1,7 +1,7 @@
require './spec/support/sidekiq'
Gitlab::Seeder.quiet do
- Project.all.each do |project|
+ Project.not_mass_generated.each do |project|
5.times do |i|
milestone_params = {
title: "v#{i}.0",
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 4af545614f7..29f2fabbd5f 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -4,7 +4,13 @@ Gitlab::Seeder.quiet do
# Limit the number of merge requests per project to avoid long seeds
MAX_NUM_MERGE_REQUESTS = 10
- Project.non_archived.with_merge_requests_enabled.reject(&:empty_repo?).each do |project|
+ projects = Project
+ .non_archived
+ .with_merge_requests_enabled
+ .not_mass_generated
+ .reject(&:empty_repo?)
+
+ projects.each do |project|
branches = project.repository.branch_names.sample(MAX_NUM_MERGE_REQUESTS * 2)
branches.each do |branch_name|
diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb
index c405ecfdaf3..13eadc35e07 100644
--- a/db/fixtures/development/11_keys.rb
+++ b/db/fixtures/development/11_keys.rb
@@ -9,7 +9,7 @@ Sidekiq::Testing.disable! do
# that it falls under `Sidekiq::Testing.disable!`.
Key.skip_callback(:commit, :after, :add_to_shell)
- User.first(10).each do |user|
+ User.not_mass_generated.first(10).each do |user|
key = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{user.id + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
key = user.keys.create(
diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb
index a9f4069a0f8..0ee9058a20b 100644
--- a/db/fixtures/development/12_snippets.rb
+++ b/db/fixtures/development/12_snippets.rb
@@ -25,7 +25,7 @@ end
eos
50.times do |i|
- user = User.all.sample
+ user = User.not_mass_generated.sample
PersonalSnippet.seed(:id, [{
id: i,
diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb
index 5c8b681fa92..468caac23f9 100644
--- a/db/fixtures/development/14_pipelines.rb
+++ b/db/fixtures/development/14_pipelines.rb
@@ -214,7 +214,7 @@ class Gitlab::Seeder::Pipelines
end
Gitlab::Seeder.quiet do
- Project.all.sample(5).each do |project|
+ Project.not_mass_generated.sample(5).each do |project|
project_builds = Gitlab::Seeder::Pipelines.new(project)
project_builds.seed!
end
diff --git a/db/fixtures/development/16_protected_branches.rb b/db/fixtures/development/16_protected_branches.rb
index 39d466fb43f..2b492ac1f61 100644
--- a/db/fixtures/development/16_protected_branches.rb
+++ b/db/fixtures/development/16_protected_branches.rb
@@ -3,7 +3,7 @@ require './spec/support/sidekiq'
Gitlab::Seeder.quiet do
admin_user = User.find(1)
- Project.all.each do |project|
+ Project.not_mass_generated.each do |project|
params = {
name: 'master'
}
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb
index b7ddeef95b8..606a4cb1dde 100644
--- a/db/fixtures/development/17_cycle_analytics.rb
+++ b/db/fixtures/development/17_cycle_analytics.rb
@@ -217,7 +217,7 @@ Gitlab::Seeder.quiet do
flag = 'SEED_CYCLE_ANALYTICS'
if ENV[flag]
- Project.find_each do |project|
+ Project.not_mass_generated.find_each do |project|
# This seed naively assumes that every project has a repository, and every
# repository has a `master` branch, which may be the case for a pristine
# GDK seed, but is almost never true for a GDK that's actually had
diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb
index 3e227928a29..08363804216 100644
--- a/db/fixtures/development/19_environments.rb
+++ b/db/fixtures/development/19_environments.rb
@@ -67,7 +67,7 @@ class Gitlab::Seeder::Environments
end
Gitlab::Seeder.quiet do
- Project.all.sample(5).each do |project|
+ Project.not_mass_generated.sample(5).each do |project|
project_environments = Gitlab::Seeder::Environments.new(project)
project_environments.seed!
end
diff --git a/db/fixtures/development/23_spam_logs.rb b/db/fixtures/development/23_spam_logs.rb
index 81cc13e6b2d..4a839f5bc23 100644
--- a/db/fixtures/development/23_spam_logs.rb
+++ b/db/fixtures/development/23_spam_logs.rb
@@ -22,7 +22,7 @@ module Db
end
def self.random_user
- User.find(User.pluck(:id).sample)
+ User.find(User.not_mass_generated.pluck(:id).sample)
end
end
end
diff --git a/db/fixtures/development/24_forks.rb b/db/fixtures/development/24_forks.rb
index 971c6f0d0c8..fa16b2a1d93 100644
--- a/db/fixtures/development/24_forks.rb
+++ b/db/fixtures/development/24_forks.rb
@@ -2,8 +2,8 @@ require './spec/support/sidekiq'
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
- User.all.sample(10).each do |user|
- source_project = Project.public_only.sample
+ User.not_mass_generated.sample(10).each do |user|
+ source_project = Project.not_mass_generated.public_only.sample
##
# 03_project.rb might not have created a public project because
diff --git a/db/migrate/20180215181245_users_name_lower_index.rb b/db/migrate/20180215181245_users_name_lower_index.rb
index 3b80601a727..fa1a115a78a 100644
--- a/db/migrate/20180215181245_users_name_lower_index.rb
+++ b/db/migrate/20180215181245_users_name_lower_index.rb
@@ -20,10 +20,6 @@ class UsersNameLowerIndex < ActiveRecord::Migration[4.2]
def down
return unless Gitlab::Database.postgresql?
- if supports_drop_index_concurrently?
- execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
- else
- execute "DROP INDEX IF EXISTS #{INDEX_NAME}"
- end
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
end
end
diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb
index 3fe90c3fbb1..fa74330d5d9 100644
--- a/db/migrate/20180504195842_project_name_lower_index.rb
+++ b/db/migrate/20180504195842_project_name_lower_index.rb
@@ -22,11 +22,7 @@ class ProjectNameLowerIndex < ActiveRecord::Migration[4.2]
return unless Gitlab::Database.postgresql?
disable_statement_timeout do
- if supports_drop_index_concurrently?
- execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
- else
- execute "DROP INDEX IF EXISTS #{INDEX_NAME}"
- end
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
end
end
end
diff --git a/db/migrate/20180902070406_create_group_group_links.rb b/db/migrate/20180902070406_create_group_group_links.rb
new file mode 100644
index 00000000000..95fed0ebf96
--- /dev/null
+++ b/db/migrate/20180902070406_create_group_group_links.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CreateGroupGroupLinks < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ create_table :group_group_links do |t|
+ t.timestamps_with_timezone null: false
+
+ t.references :shared_group, null: false,
+ index: false,
+ foreign_key: { on_delete: :cascade,
+ to_table: :namespaces }
+ t.references :shared_with_group, null: false,
+ foreign_key: { on_delete: :cascade,
+ to_table: :namespaces }
+ t.date :expires_at
+ t.index [:shared_group_id, :shared_with_group_id],
+ { unique: true,
+ name: 'index_group_group_links_on_shared_group_and_shared_with_group' }
+ t.integer :group_access, { limit: 2,
+ default: 30, # Gitlab::Access::DEVELOPER
+ null: false }
+ end
+ end
+
+ def down
+ drop_table :group_group_links
+ end
+end
diff --git a/db/migrate/20190703171157_add_sourcing_epic_dates.rb b/db/migrate/20190703171157_add_sourcing_epic_dates.rb
new file mode 100644
index 00000000000..202e2098d5b
--- /dev/null
+++ b/db/migrate/20190703171157_add_sourcing_epic_dates.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddSourcingEpicDates < ActiveRecord::Migration[5.1]
+ DOWNTIME = false
+
+ def change
+ add_column :epics, :start_date_sourcing_epic_id, :integer
+ add_column :epics, :due_date_sourcing_epic_id, :integer
+ end
+end
diff --git a/db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb b/db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb
new file mode 100644
index 00000000000..4995a3cd03f
--- /dev/null
+++ b/db/migrate/20190703171555_add_sourcing_epic_dates_fks.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddSourcingEpicDatesFks < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :epics, :start_date_sourcing_epic_id, where: 'start_date_sourcing_epic_id is not null'
+ add_concurrent_index :epics, :due_date_sourcing_epic_id, where: 'due_date_sourcing_epic_id is not null'
+
+ add_concurrent_foreign_key :epics, :epics, column: :start_date_sourcing_epic_id, on_delete: :nullify
+ add_concurrent_foreign_key :epics, :epics, column: :due_date_sourcing_epic_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :epics, column: :start_date_sourcing_epic_id
+ remove_foreign_key_if_exists :epics, column: :due_date_sourcing_epic_id
+
+ remove_concurrent_index :epics, :start_date_sourcing_epic_id
+ remove_concurrent_index :epics, :due_date_sourcing_epic_id
+ end
+end
diff --git a/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb b/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb
index fc4bc1a423b..477f8a850f8 100644
--- a/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb
+++ b/db/migrate/20190805140353_remove_rendundant_index_from_releases.rb
@@ -12,10 +12,13 @@ class RemoveRendundantIndexFromReleases < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
- remove_concurrent_index :releases, :project_id
+ remove_concurrent_index_by_name :releases, 'index_releases_on_project_id'
+
+ # This is an extra index that is not present in db/schema.rb but known to exist on some installs
+ remove_concurrent_index_by_name :releases, 'releases_project_id_idx' if index_exists_by_name?(:releases, 'releases_project_id_idx')
end
def down
- add_concurrent_index :releases, :project_id
+ add_concurrent_index :releases, :project_id, name: 'index_releases_on_project_id'
end
end
diff --git a/db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb b/db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb
new file mode 100644
index 00000000000..e624642c2fc
--- /dev/null
+++ b/db/migrate/20190827222124_add_sourcegraph_configuration_to_application_settings.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddSourcegraphConfigurationToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def up
+ add_column(:application_settings, :sourcegraph_enabled, :boolean, default: false, null: false)
+ add_column(:application_settings, :sourcegraph_url, :string, null: true, limit: 255)
+ end
+
+ def down
+ remove_column(:application_settings, :sourcegraph_enabled)
+ remove_column(:application_settings, :sourcegraph_url)
+ end
+end
diff --git a/db/migrate/20190910211526_create_packages_conan_file_metadata.rb b/db/migrate/20190910211526_create_packages_conan_file_metadata.rb
new file mode 100644
index 00000000000..0f8dacb72de
--- /dev/null
+++ b/db/migrate/20190910211526_create_packages_conan_file_metadata.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreatePackagesConanFileMetadata < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :packages_conan_file_metadata do |t|
+ t.references :package_file, index: { unique: true }, null: false, foreign_key: { to_table: :packages_package_files, on_delete: :cascade }, type: :bigint
+ t.timestamps_with_timezone
+ t.string "recipe_revision", null: false, default: "0", limit: 255
+ t.string "package_revision", limit: 255
+ t.string "conan_package_reference", limit: 255
+ t.integer "conan_file_type", limit: 2, null: false
+ end
+ end
+end
diff --git a/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb b/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb
new file mode 100644
index 00000000000..0ba9d8e6c89
--- /dev/null
+++ b/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddCleanupStatusToCluster < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:clusters, :cleanup_status,
+ :smallint,
+ default: 1,
+ allow_null: false)
+ end
+
+ def down
+ remove_column(:clusters, :cleanup_status)
+ end
+end
diff --git a/db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb b/db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb
new file mode 100644
index 00000000000..4e71905e3a3
--- /dev/null
+++ b/db/migrate/20190918121135_add_cleanup_status_reason_to_cluster.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddCleanupStatusReasonToCluster < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :clusters, :cleanup_status_reason, :text
+ end
+end
diff --git a/db/migrate/20190930153535_create_zoom_meetings.rb b/db/migrate/20190930153535_create_zoom_meetings.rb
new file mode 100644
index 00000000000..6b92c53da79
--- /dev/null
+++ b/db/migrate/20190930153535_create_zoom_meetings.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class CreateZoomMeetings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ ZOOM_MEETING_STATUS_ADDED = 1
+
+ def change
+ create_table :zoom_meetings do |t|
+ t.references :project, foreign_key: { on_delete: :cascade },
+ null: false
+ t.references :issue, foreign_key: { on_delete: :cascade },
+ null: false
+ t.timestamps_with_timezone null: false
+ t.integer :issue_status, limit: 2, default: 1, null: false
+ t.string :url, limit: 255
+
+ t.index [:issue_id, :issue_status], unique: true,
+ where: "issue_status = #{ZOOM_MEETING_STATUS_ADDED}"
+ end
+ end
+end
diff --git a/db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb b/db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb
new file mode 100644
index 00000000000..8910dc0d9fb
--- /dev/null
+++ b/db/migrate/20191002123516_create_clusters_applications_elastic_stack.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class CreateClustersApplicationsElasticStack < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :clusters_applications_elastic_stacks do |t|
+ t.timestamps_with_timezone null: false
+ t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.integer :status, null: false
+ t.string :version, null: false, limit: 255
+ t.string :kibana_hostname, limit: 255
+ t.text :status_reason
+ t.index :cluster_id, unique: true
+ end
+ end
+end
diff --git a/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb b/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
index 94d16e921df..71d10153422 100644
--- a/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
+++ b/db/migrate/20191003015155_add_self_managed_prometheus_alerts.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class AddSelfManagedPrometheusAlerts < ActiveRecord::Migration[5.2]
- # Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
diff --git a/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb b/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb
new file mode 100644
index 00000000000..86d581a4383
--- /dev/null
+++ b/db/migrate/20191003161031_add_mark_for_deletion_to_projects.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddMarkForDeletionToProjects < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :projects, :marked_for_deletion_at, :date
+ add_column :projects, :marked_for_deletion_by_user_id, :integer
+ end
+end
diff --git a/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb b/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb
new file mode 100644
index 00000000000..d6ef6509fff
--- /dev/null
+++ b/db/migrate/20191003161032_add_mark_for_deletion_indexes_to_projects.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddMarkForDeletionIndexesToProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :projects, :users, column: :marked_for_deletion_by_user_id, on_delete: :nullify
+ add_concurrent_index :projects, :marked_for_deletion_by_user_id, where: 'marked_for_deletion_by_user_id IS NOT NULL'
+ end
+
+ def down
+ remove_foreign_key_if_exists :projects, column: :marked_for_deletion_by_user_id
+ remove_concurrent_index :projects, :marked_for_deletion_by_user_id
+ end
+end
diff --git a/db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb b/db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb
new file mode 100644
index 00000000000..c5f5a8cd70c
--- /dev/null
+++ b/db/migrate/20191003195218_add_pendo_enabled_to_application_settings.rb
@@ -0,0 +1,15 @@
+class AddPendoEnabledToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :application_settings, :pendo_enabled, :boolean, default: false, allow_null: false
+ end
+
+ def down
+ remove_column :application_settings, :pendo_enabled
+ end
+end
diff --git a/db/migrate/20191003195620_add_pendo_url_to_application_settings.rb b/db/migrate/20191003195620_add_pendo_url_to_application_settings.rb
new file mode 100644
index 00000000000..cc0895f8bee
--- /dev/null
+++ b/db/migrate/20191003195620_add_pendo_url_to_application_settings.rb
@@ -0,0 +1,9 @@
+class AddPendoUrlToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :pendo_url, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191004080818_add_productivity_analytics_start_date.rb b/db/migrate/20191004080818_add_productivity_analytics_start_date.rb
new file mode 100644
index 00000000000..287b0755bc1
--- /dev/null
+++ b/db/migrate/20191004080818_add_productivity_analytics_start_date.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddProductivityAnalyticsStartDate < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :productivity_analytics_start_date, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20191004081520_fill_productivity_analytics_start_date.rb b/db/migrate/20191004081520_fill_productivity_analytics_start_date.rb
new file mode 100644
index 00000000000..9432cd68708
--- /dev/null
+++ b/db/migrate/20191004081520_fill_productivity_analytics_start_date.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+# Expected migration duration: 1 minute
+class FillProductivityAnalyticsStartDate < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_request_metrics, :merged_at,
+ where: "merged_at > '2019-09-01' AND commits_count IS NOT NULL",
+ name: 'fill_productivity_analytics_start_date_tmp_index'
+
+ execute(
+ <<SQL
+ UPDATE application_settings
+ SET productivity_analytics_start_date = COALESCE((SELECT MIN(merged_at) FROM merge_request_metrics
+ WHERE merged_at > '2019-09-01' AND commits_count IS NOT NULL), NOW())
+SQL
+ )
+
+ remove_concurrent_index :merge_request_metrics, :merged_at,
+ name: 'fill_productivity_analytics_start_date_tmp_index'
+ end
+
+ def down
+ execute('UPDATE application_settings SET productivity_analytics_start_date = NULL')
+ end
+end
diff --git a/db/migrate/20191009100244_add_geo_design_repository_counters.rb b/db/migrate/20191009100244_add_geo_design_repository_counters.rb
new file mode 100644
index 00000000000..26387453f88
--- /dev/null
+++ b/db/migrate/20191009100244_add_geo_design_repository_counters.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddGeoDesignRepositoryCounters < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_table :geo_node_statuses do |t|
+ t.column :design_repositories_count, :integer
+ t.column :design_repositories_synced_count, :integer
+ t.column :design_repositories_failed_count, :integer
+ t.column :design_repositories_registry_count, :integer
+ end
+ end
+end
diff --git a/db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb b/db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb
new file mode 100644
index 00000000000..86c3c540e5e
--- /dev/null
+++ b/db/migrate/20191009110124_add_has_exposed_artifacts_to_ci_builds_metadata.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddHasExposedArtifactsToCiBuildsMetadata < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :ci_builds_metadata, :has_exposed_artifacts, :boolean
+ end
+
+ def down
+ remove_column :ci_builds_metadata, :has_exposed_artifacts
+ end
+end
diff --git a/db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb b/db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb
new file mode 100644
index 00000000000..6b8c452a62a
--- /dev/null
+++ b/db/migrate/20191009110757_add_index_to_ci_builds_metadata_has_exposed_artifacts.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToCiBuildsMetadataHasExposedArtifacts < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_builds_metadata, [:build_id], where: "has_exposed_artifacts IS TRUE", name: 'index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts'
+ end
+
+ def down
+ remove_concurrent_index_by_name :ci_builds_metadata, 'index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts'
+ end
+end
diff --git a/db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb b/db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb
new file mode 100644
index 00000000000..a40ce8dbee5
--- /dev/null
+++ b/db/migrate/20191010174846_add_snowplow_iglu_registry_url_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSnowplowIgluRegistryUrlToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :snowplow_iglu_registry_url, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb b/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb
new file mode 100644
index 00000000000..79546e33253
--- /dev/null
+++ b/db/migrate/20191011084019_add_project_deletion_adjourned_period_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddProjectDeletionAdjournedPeriodToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ DEFAULT_NUMBER_OF_DAYS_BEFORE_REMOVAL = 7
+
+ def change
+ add_column :application_settings, :deletion_adjourned_period, :integer, default: DEFAULT_NUMBER_OF_DAYS_BEFORE_REMOVAL, null: false
+ end
+end
diff --git a/db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb b/db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb
new file mode 100644
index 00000000000..0a58f0a89aa
--- /dev/null
+++ b/db/migrate/20191013100213_add_squash_commit_sha_to_merge_requests.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSquashCommitShaToMergeRequests < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :merge_requests, :squash_commit_sha, :binary
+ end
+end
diff --git a/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb b/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb
new file mode 100644
index 00000000000..2359cc2e826
--- /dev/null
+++ b/db/migrate/20191014025629_rename_design_management_version_user_to_author.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenameDesignManagementVersionUserToAuthor < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :design_management_versions, :user_id, :author_id
+ end
+
+ def down
+ undo_rename_column_concurrently :design_management_versions, :user_id, :author_id
+ end
+end
diff --git a/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb b/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb
new file mode 100644
index 00000000000..30e076f1fe6
--- /dev/null
+++ b/db/migrate/20191014030730_add_author_index_to_design_management_versions.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddAuthorIndexToDesignManagementVersions < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :design_management_versions, :author_id, where: 'author_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :design_management_versions, :author_id
+ end
+end
diff --git a/db/migrate/20191016133352_create_ci_subscriptions_projects.rb b/db/migrate/20191016133352_create_ci_subscriptions_projects.rb
new file mode 100644
index 00000000000..00ab2c19193
--- /dev/null
+++ b/db/migrate/20191016133352_create_ci_subscriptions_projects.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class CreateCiSubscriptionsProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ create_table :ci_subscriptions_projects do |t|
+ t.references :downstream_project, null: false, index: false, foreign_key: { to_table: :projects, on_delete: :cascade }
+ t.references :upstream_project, null: false, foreign_key: { to_table: :projects, on_delete: :cascade }
+ end
+
+ add_index :ci_subscriptions_projects, [:downstream_project_id, :upstream_project_id],
+ unique: true, name: 'index_ci_subscriptions_projects_unique_subscription'
+ end
+end
diff --git a/db/migrate/20191017001326_create_users_security_dashboard_projects.rb b/db/migrate/20191017001326_create_users_security_dashboard_projects.rb
new file mode 100644
index 00000000000..398401dbee6
--- /dev/null
+++ b/db/migrate/20191017001326_create_users_security_dashboard_projects.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateUsersSecurityDashboardProjects < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+ INDEX_NAME = 'users_security_dashboard_projects_unique_index'
+
+ def change
+ create_table :users_security_dashboard_projects, id: false do |t|
+ t.references :user, null: false, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, index: false, foreign_key: { on_delete: :cascade }
+ end
+
+ add_index :users_security_dashboard_projects, [:project_id, :user_id], name: INDEX_NAME, unique: true
+ end
+end
diff --git a/db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb b/db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb
new file mode 100644
index 00000000000..021bf7d9870
--- /dev/null
+++ b/db/migrate/20191017094449_add_remove_source_branch_after_merge_to_projects.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddRemoveSourceBranchAfterMergeToProjects < ActiveRecord::Migration[5.1]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def up
+ add_column :projects, :remove_source_branch_after_merge, :boolean
+ end
+
+ def down
+ remove_column :projects, :remove_source_branch_after_merge
+ end
+end
diff --git a/db/migrate/20191017134513_add_deployment_merge_requests.rb b/db/migrate/20191017134513_add_deployment_merge_requests.rb
new file mode 100644
index 00000000000..dbe09463d22
--- /dev/null
+++ b/db/migrate/20191017134513_add_deployment_merge_requests.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class AddDeploymentMergeRequests < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :deployment_merge_requests, id: false do |t|
+ t.references(
+ :deployment,
+ foreign_key: { on_delete: :cascade },
+ type: :integer,
+ index: false,
+ null: false
+ )
+
+ t.references(
+ :merge_request,
+ foreign_key: { on_delete: :cascade },
+ type: :integer,
+ index: true,
+ null: false
+ )
+
+ t.index(
+ [:deployment_id, :merge_request_id],
+ unique: true,
+ name: 'idx_deployment_merge_requests_unique_index'
+ )
+ end
+ end
+end
diff --git a/db/migrate/20191017191341_create_clusters_applications_crossplane.rb b/db/migrate/20191017191341_create_clusters_applications_crossplane.rb
new file mode 100644
index 00000000000..8dc25c56116
--- /dev/null
+++ b/db/migrate/20191017191341_create_clusters_applications_crossplane.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateClustersApplicationsCrossplane < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :clusters_applications_crossplane do |t|
+ t.timestamps_with_timezone null: false
+ t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.integer :status, null: false
+ t.string :version, null: false, limit: 255
+ t.string :stack, null: false, limit: 255
+ t.text :status_reason
+ t.index :cluster_id, unique: true
+ end
+ end
+end
diff --git a/db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb b/db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb
new file mode 100644
index 00000000000..a3de3f34c44
--- /dev/null
+++ b/db/migrate/20191023132005_add_merge_requests_index_on_target_project_and_branch.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddMergeRequestsIndexOnTargetProjectAndBranch < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_requests, [:target_project_id, :target_branch],
+ where: "state_id = 1 AND merge_when_pipeline_succeeds = true"
+ end
+
+ def down
+ remove_concurrent_index :merge_requests, [:target_project_id, :target_branch]
+ end
+end
diff --git a/db/migrate/20191023152913_add_default_and_free_plans.rb b/db/migrate/20191023152913_add_default_and_free_plans.rb
new file mode 100644
index 00000000000..4f5f8000386
--- /dev/null
+++ b/db/migrate/20191023152913_add_default_and_free_plans.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddDefaultAndFreePlans < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ class Plan < ApplicationRecord
+ end
+
+ def up
+ plan_names.each do |plan_name|
+ Plan.create_with(title: plan_name.titleize).find_or_create_by(name: plan_name)
+ end
+ end
+
+ def down
+ Plan.where(name: plan_names).delete_all
+ end
+
+ private
+
+ def plan_names
+ [
+ ('free' if Gitlab.com?),
+ 'default'
+ ].compact
+ end
+end
diff --git a/db/migrate/20191024134020_add_index_to_zoom_meetings.rb b/db/migrate/20191024134020_add_index_to_zoom_meetings.rb
new file mode 100644
index 00000000000..ef3657b6a5e
--- /dev/null
+++ b/db/migrate/20191024134020_add_index_to_zoom_meetings.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToZoomMeetings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :zoom_meetings, :issue_status
+ end
+
+ def down
+ remove_concurrent_index :zoom_meetings, :issue_status if index_exists?(:zoom_meetings, :issue_status)
+ end
+end
diff --git a/db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb b/db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb
new file mode 100644
index 00000000000..9d19279510a
--- /dev/null
+++ b/db/migrate/20191026124116_set_application_settings_default_project_and_snippet_visibility.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class SetApplicationSettingsDefaultProjectAndSnippetVisibility < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ change_column_null :application_settings, :default_project_visibility, false, 0
+ change_column_default :application_settings, :default_project_visibility, from: nil, to: 0
+
+ change_column_null :application_settings, :default_snippet_visibility, false, 0
+ change_column_default :application_settings, :default_snippet_visibility, from: nil, to: 0
+ end
+end
diff --git a/db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb b/db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb
new file mode 100644
index 00000000000..18a8a2306e2
--- /dev/null
+++ b/db/migrate/20191028162543_add_setup_for_company_to_user_preferences.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddSetupForCompanyToUserPreferences < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :user_preferences, :setup_for_company, :boolean
+ end
+end
diff --git a/db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb b/db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb
new file mode 100644
index 00000000000..4e3b2da670e
--- /dev/null
+++ b/db/migrate/20191028184740_rename_snowplow_site_id_to_snowplow_app_id.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenameSnowplowSiteIdToSnowplowAppId < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :application_settings, :snowplow_site_id, :snowplow_app_id
+ end
+
+ def down
+ undo_rename_column_concurrently :application_settings, :snowplow_site_id, :snowplow_app_id
+ end
+end
diff --git a/db/migrate/20191029125305_create_packages_conan_metadata.rb b/db/migrate/20191029125305_create_packages_conan_metadata.rb
new file mode 100644
index 00000000000..c6abc509e41
--- /dev/null
+++ b/db/migrate/20191029125305_create_packages_conan_metadata.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreatePackagesConanMetadata < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ create_table :packages_conan_metadata do |t|
+ t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
+ t.timestamps_with_timezone
+ t.string "package_username", null: false, limit: 255
+ t.string "package_channel", null: false, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb b/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb
new file mode 100644
index 00000000000..8db11724874
--- /dev/null
+++ b/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class AddEnabledToGrafanaIntegrations < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(
+ :grafana_integrations,
+ :enabled,
+ :boolean,
+ allow_null: false,
+ default: false
+ )
+ end
+
+ def down
+ remove_column(:grafana_integrations, :enabled)
+ end
+end
diff --git a/db/migrate/20191030135044_create_plan_limits.rb b/db/migrate/20191030135044_create_plan_limits.rb
new file mode 100644
index 00000000000..291d9824f6d
--- /dev/null
+++ b/db/migrate/20191030135044_create_plan_limits.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreatePlanLimits < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :plan_limits, id: false do |t|
+ t.references :plan, foreign_key: { on_delete: :cascade }, null: false, index: { unique: true }
+ t.integer :ci_active_pipelines, null: false, default: 0
+ t.integer :ci_pipeline_size, null: false, default: 0
+ t.integer :ci_active_jobs, null: false, default: 0
+ end
+ end
+end
diff --git a/db/migrate/20191030152934_move_limits_from_plans.rb b/db/migrate/20191030152934_move_limits_from_plans.rb
new file mode 100644
index 00000000000..020a028f648
--- /dev/null
+++ b/db/migrate/20191030152934_move_limits_from_plans.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class MoveLimitsFromPlans < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ execute <<~SQL
+ INSERT INTO plan_limits (plan_id, ci_active_pipelines, ci_pipeline_size, ci_active_jobs)
+ SELECT id, COALESCE(active_pipelines_limit, 0), COALESCE(pipeline_size_limit, 0), COALESCE(active_jobs_limit, 0)
+ FROM plans
+ SQL
+ end
+
+ def down
+ execute 'DELETE FROM plan_limits'
+ end
+end
diff --git a/db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb b/db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb
new file mode 100644
index 00000000000..b2baaee2b76
--- /dev/null
+++ b/db/migrate/20191101092917_replace_index_on_metrics_merged_at.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class ReplaceIndexOnMetricsMergedAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_request_metrics, :merged_at
+ remove_concurrent_index :merge_request_metrics, [:merged_at, :id]
+ end
+
+ def down
+ add_concurrent_index :merge_request_metrics, [:merged_at, :id]
+ remove_concurrent_index :merge_request_metrics, :merged_at
+ end
+end
diff --git a/db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb b/db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb
new file mode 100644
index 00000000000..3a167b4c67f
--- /dev/null
+++ b/db/migrate/20191103202505_add_eks_credentials_to_application_settings.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class AddEksCredentialsToApplicationSettings < ActiveRecord::Migration[5.2]
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :eks_integration_enabled, :boolean, null: false, default: false
+ add_column :application_settings, :eks_account_id, :string, limit: 128
+ add_column :application_settings, :eks_access_key_id, :string, limit: 128
+ add_column :application_settings, :encrypted_eks_secret_access_key_iv, :string, limit: 255
+ add_column :application_settings, :encrypted_eks_secret_access_key, :text
+ end
+end
diff --git a/db/migrate/20191104205020_add_license_details_to_application_settings.rb b/db/migrate/20191104205020_add_license_details_to_application_settings.rb
new file mode 100644
index 00000000000..f951ae6492d
--- /dev/null
+++ b/db/migrate/20191104205020_add_license_details_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddLicenseDetailsToApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :license_trial_ends_on, :date, null: true
+ end
+end
diff --git a/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb b/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb
new file mode 100644
index 00000000000..8fb657bf9e7
--- /dev/null
+++ b/db/migrate/20191105094558_add_report_type_to_vulnerabilities.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddReportTypeToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerabilities, :report_type, :integer, limit: 2
+ end
+end
diff --git a/db/migrate/20191105193652_add_index_on_deployments_updated_at.rb b/db/migrate/20191105193652_add_index_on_deployments_updated_at.rb
new file mode 100644
index 00000000000..10371c26dcc
--- /dev/null
+++ b/db/migrate/20191105193652_add_index_on_deployments_updated_at.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnDeploymentsUpdatedAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_COLUMNS = [:project_id, :updated_at]
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:deployments, INDEX_COLUMNS)
+ end
+
+ def down
+ remove_concurrent_index(:deployments, INDEX_COLUMNS)
+ end
+end
diff --git a/db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb b/db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb
new file mode 100644
index 00000000000..731ed82c999
--- /dev/null
+++ b/db/migrate/20191107173446_add_sourcegraph_admin_and_user_preferences.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddSourcegraphAdminAndUserPreferences < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ add_column(:application_settings, :sourcegraph_public_only, :boolean, default: true, null: false)
+ add_column(:user_preferences, :sourcegraph_enabled, :boolean)
+ end
+
+ def down
+ remove_column(:application_settings, :sourcegraph_public_only)
+ remove_column(:user_preferences, :sourcegraph_enabled)
+ end
+end
diff --git a/db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb b/db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb
new file mode 100644
index 00000000000..06849cf9bfd
--- /dev/null
+++ b/db/migrate/20191107220314_add_index_to_projects_on_marked_for_deletion.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToProjectsOnMarkedForDeletion < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :projects, :marked_for_deletion_at, where: 'marked_for_deletion_at IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :projects, :marked_for_deletion_at
+ end
+end
diff --git a/db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb b/db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb
new file mode 100644
index 00000000000..74ef0f27b3e
--- /dev/null
+++ b/db/migrate/20191111115229_add_group_id_to_import_export_uploads.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddGroupIdToImportExportUploads < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :import_export_uploads, :group_id, :bigint
+ end
+end
diff --git a/db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb b/db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb
new file mode 100644
index 00000000000..403de3f33ed
--- /dev/null
+++ b/db/migrate/20191111115431_add_group_fk_to_import_export_uploads.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddGroupFkToImportExportUploads < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :import_export_uploads, :namespaces, column: :group_id, on_delete: :cascade
+ add_concurrent_index :import_export_uploads, :group_id, unique: true, where: 'group_id IS NOT NULL'
+ end
+
+ def down
+ remove_foreign_key_without_error(:import_export_uploads, column: :group_id)
+ remove_concurrent_index(:import_export_uploads, :group_id)
+ end
+end
diff --git a/db/migrate/20191111121500_default_ci_config_path.rb b/db/migrate/20191111121500_default_ci_config_path.rb
new file mode 100644
index 00000000000..f391f5ffe99
--- /dev/null
+++ b/db/migrate/20191111121500_default_ci_config_path.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class DefaultCiConfigPath < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :application_settings, :default_ci_config_path, :string, limit: 255
+ end
+
+ def down
+ remove_column :application_settings, :default_ci_config_path
+ end
+end
diff --git a/db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb b/db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb
new file mode 100644
index 00000000000..b0c513737e8
--- /dev/null
+++ b/db/migrate/20191112115247_add_cached_markdown_version_to_vulnerabilities.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddCachedMarkdownVersionToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerabilities, :cached_markdown_version, :integer
+ end
+end
diff --git a/db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb b/db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb
new file mode 100644
index 00000000000..3893c0422c7
--- /dev/null
+++ b/db/migrate/20191112214305_add_indexes_for_projects_api_default_params.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexesForProjectsApiDefaultParams < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :projects, %i(visibility_level created_at id)
+ remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level'
+ end
+
+ def down
+ add_concurrent_index :projects, :visibility_level
+ remove_concurrent_index :projects, %i(visibility_level created_at id)
+ end
+end
diff --git a/db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb b/db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb
new file mode 100644
index 00000000000..6ebc6a72854
--- /dev/null
+++ b/db/migrate/20191112221821_add_indexes_for_projects_api_default_params_authenticated.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexesForProjectsApiDefaultParamsAuthenticated < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :projects, %i(created_at id)
+ remove_concurrent_index_by_name :projects, 'index_projects_on_created_at'
+ end
+
+ def down
+ add_concurrent_index :projects, :created_at
+ remove_concurrent_index_by_name :projects, 'index_projects_on_created_at_and_id'
+ end
+end
diff --git a/db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb b/db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb
new file mode 100644
index 00000000000..76cb511424e
--- /dev/null
+++ b/db/migrate/20191112232338_ensure_no_empty_milestone_titles.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class EnsureNoEmptyMilestoneTitles < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ loop do
+ rows_updated = exec_update <<~SQL
+ UPDATE milestones SET title = '%BLANK' WHERE id IN (SELECT id FROM milestones WHERE title = '' LIMIT 500)
+ SQL
+ break if rows_updated < 500
+ end
+ end
+
+ def down; end
+end
diff --git a/db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb b/db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb
new file mode 100644
index 00000000000..ec45a729ebb
--- /dev/null
+++ b/db/migrate/20191114173508_add_resolved_attributes_to_vulnerabilities.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddResolvedAttributesToVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :vulnerabilities, :resolved_by_id, :bigint
+ add_column :vulnerabilities, :resolved_at, :datetime_with_timezone
+ end
+
+ def down
+ remove_column :vulnerabilities, :resolved_at
+ remove_column :vulnerabilities, :resolved_by_id
+ end
+end
diff --git a/db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb b/db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb
new file mode 100644
index 00000000000..e0a125ca756
--- /dev/null
+++ b/db/migrate/20191114173602_add_foreign_key_on_resolved_by_id_to_vulnerabilities.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddForeignKeyOnResolvedByIdToVulnerabilities < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :vulnerabilities, :resolved_by_id
+ add_concurrent_foreign_key :vulnerabilities, :users, column: :resolved_by_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key :vulnerabilities, column: :resolved_by_id
+ remove_concurrent_index :vulnerabilities, :resolved_by_id
+ end
+end
diff --git a/db/migrate/20191115091425_create_vulnerability_issue_links.rb b/db/migrate/20191115091425_create_vulnerability_issue_links.rb
new file mode 100644
index 00000000000..8398b6357c4
--- /dev/null
+++ b/db/migrate/20191115091425_create_vulnerability_issue_links.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityIssueLinks < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :vulnerability_issue_links do |t|
+ # index: false because idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id refers the same column
+ t.references :vulnerability, null: false, index: false, foreign_key: { on_delete: :cascade }
+ # index: true is implied
+ t.references :issue, null: false, foreign_key: { on_delete: :cascade }
+ t.integer 'link_type', limit: 2, null: false, default: 1 # 'related'
+ t.index %i[vulnerability_id issue_id],
+ name: 'idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id',
+ unique: true # only one link (and of only one type) is allowed
+ t.index %i[vulnerability_id link_type],
+ name: 'idx_vulnerability_issue_links_on_vulnerability_id_and_link_type',
+ where: 'link_type = 2',
+ unique: true # only one 'created' link per vulnerability is allowed
+ t.timestamps_with_timezone
+ end
+ end
+end
diff --git a/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb b/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb
index 0c4faebc548..d10887fb5d5 100644
--- a/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb
+++ b/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb
@@ -3,71 +3,17 @@
class SetSelfMonitoringProjectAlertingToken < ActiveRecord::Migration[5.2]
DOWNTIME = false
- module Migratable
- module Alerting
- class ProjectAlertingSetting < ApplicationRecord
- self.table_name = 'project_alerting_settings'
-
- belongs_to :project
-
- validates :token, presence: true
-
- attr_encrypted :token,
- mode: :per_attribute_iv,
- key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-gcm'
-
- before_validation :ensure_token
-
- private
-
- def ensure_token
- self.token ||= generate_token
- end
-
- def generate_token
- SecureRandom.hex
- end
- end
- end
-
- class Project < ApplicationRecord
- has_one :alerting_setting, inverse_of: :project, class_name: 'Alerting::ProjectAlertingSetting'
- end
-
- class ApplicationSetting < ApplicationRecord
- self.table_name = 'application_settings'
-
- belongs_to :instance_administration_project, class_name: 'Project'
-
- def self.current_without_cache
- last
- end
- end
- end
-
- def setup_alertmanager_token(project)
- return unless License.feature_available?(:prometheus_alerts)
-
- project.create_alerting_setting!
- end
-
def up
- Gitlab.ee do
- project = Migratable::ApplicationSetting.current_without_cache&.instance_administration_project
+ # no-op
+ # Converted to no-op in https://gitlab.com/gitlab-org/gitlab/merge_requests/17049.
- if project
- setup_alertmanager_token(project)
- end
- end
+ # This migration has been made a no-op because the pre-requisite migration
+ # which creates the self-monitoring project has already been removed in
+ # https://gitlab.com/gitlab-org/gitlab/merge_requests/16864. As
+ # such, this migration would do nothing.
end
def down
- Gitlab.ee do
- Migratable::ApplicationSetting.current_without_cache
- &.instance_administration_project
- &.alerting_setting
- &.destroy!
- end
+ # no-op
end
end
diff --git a/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb b/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
index 23d3bbbc395..cd759735f00 100644
--- a/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
+++ b/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
@@ -6,7 +6,7 @@ class ScheduleProductivityAnalyticsBackfill < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
- # no-op since the scheduling times out on GitLab.com
+ # no-op since the migration was removed
end
def down
diff --git a/db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb b/db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb
new file mode 100644
index 00000000000..86fe0f26681
--- /dev/null
+++ b/db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb
@@ -0,0 +1,35 @@
+# 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 ScheduleEpicIssuesAfterEpicsMove < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INTERVAL = 5.minutes.to_i
+ BATCH_SIZE = 100
+ MIGRATION = 'MoveEpicIssuesAfterEpics'
+
+ disable_ddl_transaction!
+
+ class Epic < ActiveRecord::Base
+ self.table_name = 'epics'
+
+ include ::EachBatch
+ end
+
+ def up
+ return unless ::Gitlab.ee?
+
+ Epic.each_batch(of: BATCH_SIZE) do |batch, index|
+ range = batch.pluck('MIN(id)', 'MAX(id)').first
+ delay = index * INTERVAL
+ BackgroundMigrationWorker.perform_in(delay, MIGRATION, *range)
+ end
+ end
+
+ def down
+ # no need
+ end
+end
diff --git a/db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb b/db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb
new file mode 100644
index 00000000000..c1f4b7e42ab
--- /dev/null
+++ b/db/post_migrate/20191008143850_fix_any_approver_rule_for_projects.rb
@@ -0,0 +1,51 @@
+# 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 FixAnyApproverRuleForProjects < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+ BATCH_SIZE = 1000
+
+ disable_ddl_transaction!
+
+ class ApprovalProjectRule < ActiveRecord::Base
+ NON_EXISTENT_RULE_TYPE = 4
+ ANY_APPROVER_RULE_TYPE = 3
+
+ include EachBatch
+
+ self.table_name = 'approval_project_rules'
+
+ scope :any_approver, -> { where(rule_type: ANY_APPROVER_RULE_TYPE) }
+ scope :non_existent_rule_type, -> { where(rule_type: NON_EXISTENT_RULE_TYPE) }
+ end
+
+ def up
+ return unless Gitlab.ee?
+
+ # Remove approval project rule with rule type 4 if the project has a rule with rule_type 3
+ #
+ # Currently, there is no projects on gitlab.com which have both rules with 3 and 4 rule type
+ # There's a code-level validation for a rule, which doesn't allow to create rules with the same names
+ #
+ # But in order to avoid failing the update query due to uniqueness constraint
+ # Let's run the delete query to be sure
+ project_ids = FixAnyApproverRuleForProjects::ApprovalProjectRule.any_approver.select(:project_id)
+ FixAnyApproverRuleForProjects::ApprovalProjectRule
+ .non_existent_rule_type
+ .where(project_id: project_ids)
+ .delete_all
+
+ # Set approval project rule types to 3
+ # Currently there are 18_445 records to be updated
+ FixAnyApproverRuleForProjects::ApprovalProjectRule.non_existent_rule_type.each_batch(of: BATCH_SIZE) do |rules|
+ rules.update_all(rule_type: FixAnyApproverRuleForProjects::ApprovalProjectRule::ANY_APPROVER_RULE_TYPE)
+ end
+ end
+
+ def down
+ # The migration doesn't leave the database in an inconsistent state
+ # And can be run multiple times
+ end
+end
diff --git a/db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb b/db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb
new file mode 100644
index 00000000000..e7132cbeeb7
--- /dev/null
+++ b/db/post_migrate/20191014030134_cleanup_design_management_version_user_to_author_rename.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CleanupDesignManagementVersionUserToAuthorRename < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :design_management_versions, :user_id, :author_id
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :design_management_versions, :user_id, :author_id
+ end
+end
diff --git a/db/post_migrate/20191017045817_schedule_fix_gitlab_com_pages_access_level.rb b/db/post_migrate/20191017045817_schedule_fix_gitlab_com_pages_access_level.rb
new file mode 100644
index 00000000000..fc44568ea17
--- /dev/null
+++ b/db/post_migrate/20191017045817_schedule_fix_gitlab_com_pages_access_level.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.
+
+# Code of this migration was removed after execution on gitlab.com
+# https://gitlab.com/gitlab-org/gitlab/issues/34018
+# Empty migration is left here to avoid any problems with rolling back
+class ScheduleFixGitlabComPagesAccessLevel < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ end
+
+ def down
+ end
+end
diff --git a/db/post_migrate/20191017180026_drop_ci_build_trace_sections_id.rb b/db/post_migrate/20191017180026_drop_ci_build_trace_sections_id.rb
new file mode 100644
index 00000000000..0405e23b465
--- /dev/null
+++ b/db/post_migrate/20191017180026_drop_ci_build_trace_sections_id.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class DropCiBuildTraceSectionsId < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ ##
+ # This column has already been ignored since 12.4
+ # See https://gitlab.com/gitlab-org/gitlab/issues/32569
+ remove_column :ci_build_trace_sections, :id
+ end
+
+ def down
+ ##
+ # We don't backfill serial ids as it's not used in application code
+ # and quite expensive process.
+ add_column :ci_build_trace_sections, :id, :bigint
+ end
+end
diff --git a/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb b/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb
new file mode 100644
index 00000000000..64abe93b3e8
--- /dev/null
+++ b/db/post_migrate/20191021101942_remove_empty_github_service_templates.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+## It's expected to delete one record on GitLab.com
+#
+class RemoveEmptyGithubServiceTemplates < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ class Service < ActiveRecord::Base
+ self.table_name = 'services'
+ self.inheritance_column = :_type_disabled
+
+ serialize :properties, JSON
+ end
+
+ def up
+ relationship.where(properties: {}).delete_all
+ end
+
+ def down
+ relationship.find_or_create_by!(properties: {})
+ end
+
+ private
+
+ def relationship
+ RemoveEmptyGithubServiceTemplates::Service.where(template: true, type: 'GithubService')
+ end
+end
diff --git a/db/post_migrate/20191022113635_nullify_feature_flag_plaintext_tokens.rb b/db/post_migrate/20191022113635_nullify_feature_flag_plaintext_tokens.rb
new file mode 100644
index 00000000000..9ade1454844
--- /dev/null
+++ b/db/post_migrate/20191022113635_nullify_feature_flag_plaintext_tokens.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+class NullifyFeatureFlagPlaintextTokens < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ class FeatureFlagsClient < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'operations_feature_flags_clients'
+
+ scope :with_encrypted_token, -> { where.not(token_encrypted: nil) }
+ scope :with_plaintext_token, -> { where.not(token: nil) }
+ scope :without_plaintext_token, -> { where(token: nil) }
+ end
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee?
+
+ # 7357 records to be updated on GitLab.com
+ FeatureFlagsClient.with_encrypted_token.with_plaintext_token.each_batch do |relation|
+ relation.update_all(token: nil)
+ end
+ end
+
+ def down
+ return unless Gitlab.ee?
+
+ # There is no way to restore only the tokens that were NULLifyed in the `up`
+ # but we can do is to restore _all_ of them in case it is needed.
+ say_with_time('Decrypting tokens from operations_feature_flags_clients') do
+ FeatureFlagsClient.with_encrypted_token.without_plaintext_token.find_each do |feature_flags_client|
+ token = Gitlab::CryptoHelper.aes256_gcm_decrypt(feature_flags_client.token_encrypted)
+ feature_flags_client.update_column(:token, token)
+ end
+ end
+ end
+end
diff --git a/db/post_migrate/20191029095537_cleanup_application_settings_snowplow_site_id_rename.rb b/db/post_migrate/20191029095537_cleanup_application_settings_snowplow_site_id_rename.rb
new file mode 100644
index 00000000000..83b4a2af2b6
--- /dev/null
+++ b/db/post_migrate/20191029095537_cleanup_application_settings_snowplow_site_id_rename.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CleanupApplicationSettingsSnowplowSiteIdRename < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :application_settings, :snowplow_site_id, :snowplow_app_id
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :application_settings, :snowplow_site_id, :snowplow_app_id
+ end
+end
diff --git a/db/post_migrate/20191030193050_remove_pendo_from_application_settings.rb b/db/post_migrate/20191030193050_remove_pendo_from_application_settings.rb
new file mode 100644
index 00000000000..33bbe6f8ea7
--- /dev/null
+++ b/db/post_migrate/20191030193050_remove_pendo_from_application_settings.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemovePendoFromApplicationSettings < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ remove_column :application_settings, :pendo_enabled
+ remove_column :application_settings, :pendo_url
+ end
+
+ def down
+ add_column_with_default :application_settings, :pendo_enabled, :boolean, default: false, allow_null: false
+ add_column :application_settings, :pendo_url, :string, limit: 255
+ end
+end
diff --git a/db/post_migrate/20191031112603_remove_limits_from_plans.rb b/db/post_migrate/20191031112603_remove_limits_from_plans.rb
new file mode 100644
index 00000000000..30fb6a9d193
--- /dev/null
+++ b/db/post_migrate/20191031112603_remove_limits_from_plans.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RemoveLimitsFromPlans < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ remove_column :plans, :active_pipelines_limit
+ remove_column :plans, :pipeline_size_limit
+ remove_column :plans, :active_jobs_limit
+ end
+
+ def down
+ add_column :plans, :active_pipelines_limit, :integer
+ add_column :plans, :pipeline_size_limit, :integer
+ add_column :plans, :active_jobs_limit, :integer
+ end
+end
diff --git a/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
new file mode 100644
index 00000000000..6b7a158584d
--- /dev/null
+++ b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class SetReportTypeForVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ # set report_type based on associated vulnerability_occurrences
+ execute <<~SQL
+ UPDATE vulnerabilities
+ SET report_type = vulnerability_occurrences.report_type
+ FROM vulnerability_occurrences
+ WHERE vulnerabilities.id = vulnerability_occurrences.vulnerability_id
+ SQL
+
+ # set default report_type for orphan vulnerabilities (there should be none but...)
+ execute 'UPDATE vulnerabilities SET report_type = 0 WHERE report_type IS NULL'
+
+ change_column_null :vulnerabilities, :report_type, false
+ end
+
+ def down
+ change_column_null :vulnerabilities, :report_type, true
+
+ execute 'UPDATE vulnerabilities SET report_type = NULL'
+ end
+end
diff --git a/db/post_migrate/20191105140942_add_indices_to_abuse_reports.rb b/db/post_migrate/20191105140942_add_indices_to_abuse_reports.rb
new file mode 100644
index 00000000000..2b2d04e8ccc
--- /dev/null
+++ b/db/post_migrate/20191105140942_add_indices_to_abuse_reports.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndicesToAbuseReports < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :abuse_reports, :user_id
+ end
+
+ def down
+ remove_concurrent_index :abuse_reports, :user_id
+ end
+end
diff --git a/db/post_migrate/20191112115317_change_vulnerabilities_title_html_to_nullable.rb b/db/post_migrate/20191112115317_change_vulnerabilities_title_html_to_nullable.rb
new file mode 100644
index 00000000000..6e0f3247410
--- /dev/null
+++ b/db/post_migrate/20191112115317_change_vulnerabilities_title_html_to_nullable.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class ChangeVulnerabilitiesTitleHtmlToNullable < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ change_column_null :vulnerabilities, :title_html, true
+ end
+end
diff --git a/db/post_migrate/20191114173624_set_resolved_state_on_vulnerabilities.rb b/db/post_migrate/20191114173624_set_resolved_state_on_vulnerabilities.rb
new file mode 100644
index 00000000000..b28aecdc0a3
--- /dev/null
+++ b/db/post_migrate/20191114173624_set_resolved_state_on_vulnerabilities.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class SetResolvedStateOnVulnerabilities < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ execute <<~SQL
+ -- selecting IDs for all non-orphan Findings that either have no feedback or it's a non-dismissal feedback
+ WITH resolved_vulnerability_ids AS (
+ SELECT DISTINCT vulnerability_id AS id
+ FROM vulnerability_occurrences
+ LEFT JOIN vulnerability_feedback ON vulnerability_feedback.project_fingerprint = ENCODE(vulnerability_occurrences.project_fingerprint::bytea, 'HEX')
+ WHERE vulnerability_id IS NOT NULL
+ AND (vulnerability_feedback.id IS NULL OR vulnerability_feedback.feedback_type <> 0)
+ )
+ UPDATE vulnerabilities
+ SET state = 3, resolved_by_id = closed_by_id, resolved_at = NOW()
+ FROM resolved_vulnerability_ids
+ WHERE vulnerabilities.id IN (resolved_vulnerability_ids.id)
+ AND state = 2 -- only 'closed' Vulnerabilities become 'resolved'
+ SQL
+ end
+
+ def down
+ execute <<~SQL
+ UPDATE vulnerabilities
+ SET state = 2, resolved_by_id = NULL, resolved_at = NULL -- state = 'closed'
+ WHERE state = 3 -- 'resolved'
+ SQL
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 95a4efb7e2a..e3413722991 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_10_26_041447) do
+ActiveRecord::Schema.define(version: 2019_11_15_091425) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -24,6 +24,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.datetime "updated_at"
t.text "message_html"
t.integer "cached_markdown_version"
+ t.index ["user_id"], name: "index_abuse_reports_on_user_id"
end
create_table "alerts_service_data", force: :cascade do |t|
@@ -158,8 +159,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.text "restricted_visibility_levels"
t.boolean "version_check_enabled", default: true
t.integer "max_attachment_size", default: 10, null: false
- t.integer "default_project_visibility"
- t.integer "default_snippet_visibility"
+ t.integer "default_project_visibility", default: 0, null: false
+ t.integer "default_snippet_visibility", default: 0, null: false
t.text "domain_whitelist"
t.boolean "user_oauth_applications", default: true
t.string "after_sign_out_path"
@@ -287,7 +288,6 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "hide_third_party_offers", default: false, null: false
t.boolean "snowplow_enabled", default: false, null: false
t.string "snowplow_collector_hostname"
- t.string "snowplow_site_id"
t.string "snowplow_cookie_domain"
t.boolean "instance_statistics_visibility_private", default: false, null: false
t.boolean "web_ide_clientside_preview_enabled", default: false, null: false
@@ -338,9 +338,23 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "throttle_incident_management_notification_enabled", default: false, null: false
t.integer "throttle_incident_management_notification_period_in_seconds", default: 3600
t.integer "throttle_incident_management_notification_per_period", default: 3600
+ t.string "snowplow_iglu_registry_url", limit: 255
t.integer "push_event_hooks_limit", default: 3, null: false
t.integer "push_event_activities_limit", default: 3, null: false
t.string "custom_http_clone_url_root", limit: 511
+ t.integer "deletion_adjourned_period", default: 7, null: false
+ t.date "license_trial_ends_on"
+ t.boolean "eks_integration_enabled", default: false, null: false
+ t.string "eks_account_id", limit: 128
+ t.string "eks_access_key_id", limit: 128
+ t.string "encrypted_eks_secret_access_key_iv", limit: 255
+ t.text "encrypted_eks_secret_access_key"
+ t.string "snowplow_app_id"
+ t.datetime_with_timezone "productivity_analytics_start_date"
+ t.string "default_ci_config_path", limit: 255
+ t.boolean "sourcegraph_enabled", default: false, null: false
+ t.string "sourcegraph_url", limit: 255
+ t.boolean "sourcegraph_public_only", default: true, 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"
@@ -597,7 +611,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["project_id", "name"], name: "index_ci_build_trace_section_names_on_project_id_and_name", unique: true
end
- create_table "ci_build_trace_sections", id: :serial, force: :cascade do |t|
+ create_table "ci_build_trace_sections", id: false, force: :cascade do |t|
t.integer "project_id", null: false
t.datetime "date_start", null: false
t.datetime "date_end", null: false
@@ -691,7 +705,9 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "interruptible"
t.jsonb "config_options"
t.jsonb "config_variables"
+ t.boolean "has_exposed_artifacts"
t.index ["build_id"], name: "index_ci_builds_metadata_on_build_id", unique: true
+ t.index ["build_id"], name: "index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts", where: "(has_exposed_artifacts IS TRUE)"
t.index ["build_id"], name: "index_ci_builds_metadata_on_build_id_and_interruptible", where: "(interruptible = true)"
t.index ["project_id"], name: "index_ci_builds_metadata_on_project_id"
end
@@ -911,6 +927,13 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["project_id"], name: "index_ci_stages_on_project_id"
end
+ create_table "ci_subscriptions_projects", force: :cascade do |t|
+ t.bigint "downstream_project_id", null: false
+ t.bigint "upstream_project_id", null: false
+ t.index ["downstream_project_id", "upstream_project_id"], name: "index_ci_subscriptions_projects_unique_subscription", unique: true
+ t.index ["upstream_project_id"], name: "index_ci_subscriptions_projects_on_upstream_project_id"
+ end
+
create_table "ci_trigger_requests", id: :serial, force: :cascade do |t|
t.integer "trigger_id", null: false
t.text "variables"
@@ -1037,6 +1060,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "managed", default: true, null: false
t.boolean "namespace_per_environment", default: true, null: false
t.integer "management_project_id"
+ t.integer "cleanup_status", limit: 2, default: 1, null: false
+ t.text "cleanup_status_reason"
t.index ["enabled"], name: "index_clusters_on_enabled"
t.index ["management_project_id"], name: "index_clusters_on_management_project_id", where: "(management_project_id IS NOT NULL)"
t.index ["user_id"], name: "index_clusters_on_user_id"
@@ -1053,6 +1078,28 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["cluster_id"], name: "index_clusters_applications_cert_managers_on_cluster_id", unique: true
end
+ create_table "clusters_applications_crossplane", id: :serial, force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.bigint "cluster_id", null: false
+ t.integer "status", null: false
+ t.string "version", limit: 255, null: false
+ t.string "stack", limit: 255, null: false
+ t.text "status_reason"
+ t.index ["cluster_id"], name: "index_clusters_applications_crossplane_on_cluster_id", unique: true
+ end
+
+ create_table "clusters_applications_elastic_stacks", force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ 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
+
create_table "clusters_applications_helm", id: :serial, force: :cascade do |t|
t.integer "cluster_id", null: false
t.datetime "created_at", null: false
@@ -1238,6 +1285,13 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["token_encrypted"], name: "index_deploy_tokens_on_token_encrypted", unique: true
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
+ t.index ["deployment_id", "merge_request_id"], name: "idx_deployment_merge_requests_unique_index", unique: true
+ t.index ["merge_request_id"], name: "index_deployment_merge_requests_on_merge_request_id"
+ end
+
create_table "deployments", id: :serial, force: :cascade do |t|
t.integer "iid", null: false
t.integer "project_id", null: false
@@ -1264,6 +1318,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true
t.index ["project_id", "status", "created_at"], name: "index_deployments_on_project_id_and_status_and_created_at"
t.index ["project_id", "status"], name: "index_deployments_on_project_id_and_status"
+ t.index ["project_id", "updated_at"], name: "index_deployments_on_project_id_and_updated_at"
end
create_table "description_versions", force: :cascade do |t|
@@ -1299,11 +1354,11 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
create_table "design_management_versions", force: :cascade do |t|
t.binary "sha", null: false
t.bigint "issue_id"
- t.integer "user_id"
t.datetime_with_timezone "created_at"
+ t.integer "author_id"
+ t.index ["author_id"], name: "index_design_management_versions_on_author_id", where: "(author_id IS NOT NULL)"
t.index ["issue_id"], name: "index_design_management_versions_on_issue_id"
t.index ["sha", "issue_id"], name: "index_design_management_versions_on_sha_and_issue_id", unique: true
- t.index ["user_id"], name: "index_design_management_versions_on_user_id", where: "(user_id IS NOT NULL)"
end
create_table "draft_notes", force: :cascade do |t|
@@ -1408,15 +1463,19 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.integer "parent_id"
t.integer "relative_position"
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.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"
+ t.index ["due_date_sourcing_epic_id"], name: "index_epics_on_due_date_sourcing_epic_id", where: "(due_date_sourcing_epic_id IS NOT NULL)"
t.index ["end_date"], name: "index_epics_on_end_date"
t.index ["group_id"], name: "index_epics_on_group_id"
t.index ["iid"], name: "index_epics_on_iid"
t.index ["milestone_id"], name: "index_milestone"
t.index ["parent_id"], name: "index_epics_on_parent_id"
t.index ["start_date"], name: "index_epics_on_start_date"
+ t.index ["start_date_sourcing_epic_id"], name: "index_epics_on_start_date_sourcing_epic_id", where: "(start_date_sourcing_epic_id IS NOT NULL)"
end
create_table "events", id: :serial, force: :cascade do |t|
@@ -1631,6 +1690,10 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.integer "container_repositories_synced_count"
t.integer "container_repositories_failed_count"
t.integer "container_repositories_registry_count"
+ t.integer "design_repositories_count"
+ t.integer "design_repositories_synced_count"
+ t.integer "design_repositories_failed_count"
+ t.integer "design_repositories_registry_count"
t.index ["geo_node_id"], name: "index_geo_node_statuses_on_geo_node_id", unique: true
end
@@ -1782,6 +1845,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.string "encrypted_token", limit: 255, null: false
t.string "encrypted_token_iv", limit: 255, null: false
t.string "grafana_url", limit: 1024, null: false
+ t.boolean "enabled", default: false, null: false
t.index ["project_id"], name: "index_grafana_integrations_on_project_id"
end
@@ -1795,6 +1859,17 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["key", "value"], name: "index_group_custom_attributes_on_key_and_value"
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
+ t.bigint "shared_group_id", null: false
+ t.bigint "shared_with_group_id", null: false
+ t.date "expires_at"
+ t.integer "group_access", limit: 2, default: 30, null: false
+ t.index ["shared_group_id", "shared_with_group_id"], name: "index_group_group_links_on_shared_group_and_shared_with_group", unique: true
+ t.index ["shared_with_group_id"], name: "index_group_group_links_on_shared_with_group_id"
+ end
+
create_table "historical_data", id: :serial, force: :cascade do |t|
t.date "date", null: false
t.integer "active_user_count"
@@ -1820,6 +1895,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.integer "project_id"
t.text "import_file"
t.text "export_file"
+ t.bigint "group_id"
+ t.index ["group_id"], name: "index_import_export_uploads_on_group_id", unique: true, where: "(group_id IS NOT NULL)"
t.index ["project_id"], name: "index_import_export_uploads_on_project_id"
t.index ["updated_at"], name: "index_import_export_uploads_on_updated_at"
end
@@ -2251,7 +2328,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["latest_closed_by_id"], name: "index_merge_request_metrics_on_latest_closed_by_id"
t.index ["merge_request_id", "merged_at"], name: "index_merge_request_metrics_on_merge_request_id_and_merged_at", where: "(merged_at IS NOT NULL)"
t.index ["merge_request_id"], name: "index_merge_request_metrics"
- t.index ["merged_at", "id"], name: "index_merge_request_metrics_on_merged_at_and_id"
+ t.index ["merged_at"], name: "index_merge_request_metrics_on_merged_at"
t.index ["merged_by_id"], name: "index_merge_request_metrics_on_merged_by_id"
t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id"
end
@@ -2295,6 +2372,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "allow_maintainer_to_push"
t.integer "state_id", limit: 2, default: 1, null: false
t.string "rebase_jid"
+ t.binary "squash_commit_sha"
t.index ["assignee_id"], name: "index_merge_requests_on_assignee_id"
t.index ["author_id"], name: "index_merge_requests_on_author_id"
t.index ["created_at"], name: "index_merge_requests_on_created_at"
@@ -2317,6 +2395,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true
t.index ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid_opened", where: "((state)::text = 'opened'::text)"
t.index ["target_project_id", "merge_commit_sha", "id"], name: "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id"
+ t.index ["target_project_id", "target_branch"], name: "index_merge_requests_on_target_project_id_and_target_branch", where: "((state_id = 1) AND (merge_when_pipeline_succeeds = true))"
t.index ["title"], name: "index_merge_requests_on_title"
t.index ["title"], name: "index_merge_requests_on_title_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["updated_by_id"], name: "index_merge_requests_on_updated_by_id", where: "(updated_by_id IS NOT NULL)"
@@ -2613,6 +2692,26 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["project_id", "token_encrypted"], name: "index_feature_flags_clients_on_project_id_and_token_encrypted", unique: true
end
+ create_table "packages_conan_file_metadata", force: :cascade do |t|
+ t.bigint "package_file_id", null: false
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.string "recipe_revision", limit: 255, default: "0", null: false
+ t.string "package_revision", limit: 255
+ t.string "conan_package_reference", limit: 255
+ t.integer "conan_file_type", limit: 2, null: false
+ t.index ["package_file_id"], name: "index_packages_conan_file_metadata_on_package_file_id", unique: true
+ end
+
+ create_table "packages_conan_metadata", force: :cascade do |t|
+ t.bigint "package_id", null: false
+ t.datetime_with_timezone "created_at", null: false
+ 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
+ end
+
create_table "packages_maven_metadata", force: :cascade do |t|
t.bigint "package_id", null: false
t.datetime_with_timezone "created_at", null: false
@@ -2724,14 +2823,19 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["user_id"], name: "index_personal_access_tokens_on_user_id"
end
+ create_table "plan_limits", force: :cascade do |t|
+ t.bigint "plan_id", null: false
+ t.integer "ci_active_pipelines", default: 0, null: false
+ t.integer "ci_pipeline_size", default: 0, null: false
+ t.integer "ci_active_jobs", default: 0, null: false
+ t.index ["plan_id"], name: "index_plan_limits_on_plan_id", unique: true
+ end
+
create_table "plans", id: :serial, force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "name"
t.string "title"
- t.integer "active_pipelines_limit"
- t.integer "pipeline_size_limit"
- t.integer "active_jobs_limit", default: 0
t.index ["name"], name: "index_plans_on_name"
end
@@ -3035,9 +3139,12 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.integer "max_pages_size"
t.integer "max_artifacts_size"
t.string "pull_mirror_branch_prefix", limit: 50
+ t.boolean "remove_source_branch_after_merge"
+ t.date "marked_for_deletion_at"
+ t.integer "marked_for_deletion_by_user_id"
t.index "lower((name)::text)", name: "index_projects_on_lower_name"
t.index ["archived", "pending_delete", "merge_requests_require_code_owner_approval"], name: "projects_requiring_code_owner_approval", where: "((pending_delete = false) AND (archived = false) AND (merge_requests_require_code_owner_approval = true))"
- t.index ["created_at"], name: "index_projects_on_created_at"
+ 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
t.index ["id", "repository_storage", "last_repository_updated_at"], name: "idx_projects_on_repository_storage_last_repository_updated_at"
@@ -3047,6 +3154,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
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"
t.index ["last_repository_updated_at"], name: "index_projects_on_last_repository_updated_at"
+ t.index ["marked_for_deletion_at"], name: "index_projects_on_marked_for_deletion_at", where: "(marked_for_deletion_at IS NOT NULL)"
+ t.index ["marked_for_deletion_by_user_id"], name: "index_projects_on_marked_for_deletion_by_user_id", where: "(marked_for_deletion_by_user_id IS NOT NULL)"
t.index ["mirror_last_successful_update_at"], name: "index_projects_on_mirror_last_successful_update_at"
t.index ["mirror_user_id"], name: "index_projects_on_mirror_user_id"
t.index ["name"], name: "index_projects_on_name_trigram", opclass: :gin_trgm_ops, using: :gin
@@ -3060,7 +3169,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["runners_token"], name: "index_projects_on_runners_token"
t.index ["runners_token_encrypted"], name: "index_projects_on_runners_token_encrypted"
t.index ["star_count"], name: "index_projects_on_star_count"
- t.index ["visibility_level"], name: "index_projects_on_visibility_level"
+ t.index ["visibility_level", "created_at", "id"], name: "index_projects_on_visibility_level_and_created_at_and_id"
end
create_table "prometheus_alert_events", force: :cascade do |t|
@@ -3677,6 +3786,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "time_format_in_24h"
t.string "projects_sort", limit: 64
t.boolean "show_whitespace_in_diffs", default: true, null: false
+ t.boolean "sourcegraph_enabled"
+ t.boolean "setup_for_company"
t.index ["user_id"], name: "index_user_preferences_on_user_id", unique: true
end
@@ -3816,6 +3927,13 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["user_id", "project_id"], name: "index_users_ops_dashboard_projects_on_user_id_and_project_id", unique: true
end
+ create_table "users_security_dashboard_projects", id: false, force: :cascade do |t|
+ t.bigint "user_id", null: false
+ t.bigint "project_id", null: false
+ t.index ["project_id", "user_id"], name: "users_security_dashboard_projects_unique_index", unique: true
+ t.index ["user_id"], name: "index_users_security_dashboard_projects_on_user_id"
+ end
+
create_table "users_star_projects", id: :serial, force: :cascade do |t|
t.integer "project_id", null: false
t.integer "user_id", null: false
@@ -3838,7 +3956,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.string "title", limit: 255, null: false
- t.text "title_html", null: false
+ t.text "title_html"
t.text "description"
t.text "description_html"
t.bigint "start_date_sourcing_milestone_id"
@@ -3850,6 +3968,10 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.boolean "severity_overridden", default: false
t.integer "confidence", limit: 2, null: false
t.boolean "confidence_overridden", default: false
+ t.bigint "resolved_by_id"
+ t.datetime_with_timezone "resolved_at"
+ t.integer "report_type", limit: 2, null: false
+ t.integer "cached_markdown_version"
t.index ["author_id"], name: "index_vulnerabilities_on_author_id"
t.index ["closed_by_id"], name: "index_vulnerabilities_on_closed_by_id"
t.index ["due_date_sourcing_milestone_id"], name: "index_vulnerabilities_on_due_date_sourcing_milestone_id"
@@ -3857,6 +3979,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["last_edited_by_id"], name: "index_vulnerabilities_on_last_edited_by_id"
t.index ["milestone_id"], name: "index_vulnerabilities_on_milestone_id"
t.index ["project_id"], name: "index_vulnerabilities_on_project_id"
+ t.index ["resolved_by_id"], name: "index_vulnerabilities_on_resolved_by_id"
t.index ["start_date_sourcing_milestone_id"], name: "index_vulnerabilities_on_start_date_sourcing_milestone_id"
t.index ["updated_by_id"], name: "index_vulnerabilities_on_updated_by_id"
end
@@ -3895,6 +4018,17 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["project_id", "fingerprint"], name: "index_vulnerability_identifiers_on_project_id_and_fingerprint", unique: true
end
+ create_table "vulnerability_issue_links", force: :cascade do |t|
+ t.bigint "vulnerability_id", null: false
+ t.bigint "issue_id", null: false
+ t.integer "link_type", limit: 2, default: 1, null: false
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.index ["issue_id"], name: "index_vulnerability_issue_links_on_issue_id"
+ t.index ["vulnerability_id", "issue_id"], name: "idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id", unique: true
+ t.index ["vulnerability_id", "link_type"], name: "idx_vulnerability_issue_links_on_vulnerability_id_and_link_type", unique: true, where: "(link_type = 2)"
+ end
+
create_table "vulnerability_occurrence_identifiers", force: :cascade do |t|
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
@@ -3990,6 +4124,19 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
t.index ["type"], name: "index_web_hooks_on_type"
end
+ create_table "zoom_meetings", force: :cascade do |t|
+ t.bigint "project_id", null: false
+ t.bigint "issue_id", null: false
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.integer "issue_status", limit: 2, default: 1, null: false
+ t.string "url", limit: 255
+ t.index ["issue_id", "issue_status"], name: "index_zoom_meetings_on_issue_id_and_issue_status", unique: true, where: "(issue_status = 1)"
+ t.index ["issue_id"], name: "index_zoom_meetings_on_issue_id"
+ t.index ["issue_status"], name: "index_zoom_meetings_on_issue_status"
+ t.index ["project_id"], name: "index_zoom_meetings_on_project_id"
+ end
+
add_foreign_key "alerts_service_data", "services", on_delete: :cascade
add_foreign_key "allowed_email_domains", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "analytics_cycle_analytics_group_stages", "labels", column: "end_event_label_id", on_delete: :cascade
@@ -4080,6 +4227,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "ci_sources_pipelines", "projects", name: "fk_1e53c97c0a", on_delete: :cascade
add_foreign_key "ci_stages", "ci_pipelines", column: "pipeline_id", name: "fk_fb57e6cc56", on_delete: :cascade
add_foreign_key "ci_stages", "projects", name: "fk_2360681d1d", on_delete: :cascade
+ add_foreign_key "ci_subscriptions_projects", "projects", column: "downstream_project_id", on_delete: :cascade
+ add_foreign_key "ci_subscriptions_projects", "projects", column: "upstream_project_id", on_delete: :cascade
add_foreign_key "ci_trigger_requests", "ci_triggers", column: "trigger_id", name: "fk_b8ec8b7245", on_delete: :cascade
add_foreign_key "ci_triggers", "projects", name: "fk_e3e63f966e", on_delete: :cascade
add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade
@@ -4095,6 +4244,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "clusters", "projects", column: "management_project_id", name: "fk_f05c5e5a42", on_delete: :nullify
add_foreign_key "clusters", "users", on_delete: :nullify
add_foreign_key "clusters_applications_cert_managers", "clusters", on_delete: :cascade
+ add_foreign_key "clusters_applications_crossplane", "clusters", on_delete: :cascade
+ add_foreign_key "clusters_applications_elastic_stacks", "clusters", on_delete: :cascade
add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade
add_foreign_key "clusters_applications_ingress", "clusters", on_delete: :cascade
add_foreign_key "clusters_applications_jupyter", "clusters", on_delete: :cascade
@@ -4111,6 +4262,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) 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_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
add_foreign_key "deployments", "projects", name: "fk_b9a3851b82", on_delete: :cascade
add_foreign_key "description_versions", "epics", on_delete: :cascade
@@ -4121,7 +4274,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "design_management_designs_versions", "design_management_designs", column: "design_id", name: "fk_03c671965c", on_delete: :cascade
add_foreign_key "design_management_designs_versions", "design_management_versions", column: "version_id", name: "fk_f4d25ba00c", on_delete: :cascade
add_foreign_key "design_management_versions", "issues", on_delete: :cascade
- add_foreign_key "design_management_versions", "users", name: "fk_ee16b939e5", on_delete: :nullify
+ add_foreign_key "design_management_versions", "users", column: "author_id", name: "fk_c1440b4896", on_delete: :nullify
add_foreign_key "draft_notes", "merge_requests", on_delete: :cascade
add_foreign_key "draft_notes", "users", column: "author_id", on_delete: :cascade
add_foreign_key "elasticsearch_indexed_namespaces", "namespaces", on_delete: :cascade
@@ -4130,7 +4283,9 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "epic_issues", "epics", on_delete: :cascade
add_foreign_key "epic_issues", "issues", on_delete: :cascade
add_foreign_key "epic_metrics", "epics", on_delete: :cascade
+ add_foreign_key "epics", "epics", column: "due_date_sourcing_epic_id", name: "fk_013c9f36ca", on_delete: :nullify
add_foreign_key "epics", "epics", column: "parent_id", name: "fk_25b99c1be3", on_delete: :cascade
+ add_foreign_key "epics", "epics", column: "start_date_sourcing_epic_id", name: "fk_9d480c64b2", on_delete: :nullify
add_foreign_key "epics", "milestones", on_delete: :nullify
add_foreign_key "epics", "namespaces", column: "group_id", name: "fk_f081aa4489", on_delete: :cascade
add_foreign_key "epics", "users", column: "assignee_id", name: "fk_dccd3f98fc", on_delete: :nullify
@@ -4178,7 +4333,10 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "gpg_signatures", "projects", on_delete: :cascade
add_foreign_key "grafana_integrations", "projects", on_delete: :cascade
add_foreign_key "group_custom_attributes", "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
+ add_foreign_key "import_export_uploads", "namespaces", column: "group_id", name: "fk_83319d9721", on_delete: :cascade
add_foreign_key "import_export_uploads", "projects", on_delete: :cascade
add_foreign_key "index_statuses", "projects", name: "fk_74b2492545", on_delete: :cascade
add_foreign_key "insights", "namespaces", on_delete: :cascade
@@ -4264,6 +4422,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) 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 "packages_conan_file_metadata", "packages_package_files", column: "package_file_id", on_delete: :cascade
+ add_foreign_key "packages_conan_metadata", "packages_packages", column: "package_id", on_delete: :cascade
add_foreign_key "packages_maven_metadata", "packages_packages", column: "package_id", name: "fk_be88aed360", on_delete: :cascade
add_foreign_key "packages_package_files", "packages_packages", column: "package_id", name: "fk_86f0f182f8", on_delete: :cascade
add_foreign_key "packages_package_metadata", "packages_packages", column: "package_id", on_delete: :cascade
@@ -4274,6 +4434,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "path_locks", "projects", name: "fk_5265c98f24", on_delete: :cascade
add_foreign_key "path_locks", "users"
add_foreign_key "personal_access_tokens", "users"
+ add_foreign_key "plan_limits", "plans", on_delete: :cascade
add_foreign_key "pool_repositories", "projects", column: "source_project_id", on_delete: :nullify
add_foreign_key "pool_repositories", "shards", on_delete: :restrict
add_foreign_key "project_alerting_settings", "projects", on_delete: :cascade
@@ -4301,6 +4462,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
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
+ add_foreign_key "projects", "users", column: "marked_for_deletion_by_user_id", name: "fk_25d8780d11", on_delete: :nullify
add_foreign_key "prometheus_alert_events", "projects", on_delete: :cascade
add_foreign_key "prometheus_alert_events", "prometheus_alerts", on_delete: :cascade
add_foreign_key "prometheus_alerts", "environments", on_delete: :cascade
@@ -4376,6 +4538,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "users", "namespaces", column: "managing_group_id", name: "fk_a4b8fefe3e", on_delete: :nullify
add_foreign_key "users_ops_dashboard_projects", "projects", on_delete: :cascade
add_foreign_key "users_ops_dashboard_projects", "users", on_delete: :cascade
+ add_foreign_key "users_security_dashboard_projects", "projects", on_delete: :cascade
+ add_foreign_key "users_security_dashboard_projects", "users", on_delete: :cascade
add_foreign_key "users_star_projects", "projects", name: "fk_22cd27ddfc", on_delete: :cascade
add_foreign_key "vulnerabilities", "epics", name: "fk_1d37cddf91", on_delete: :nullify
add_foreign_key "vulnerabilities", "milestones", column: "due_date_sourcing_milestone_id", name: "fk_7c5bb22a22", on_delete: :nullify
@@ -4385,6 +4549,7 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
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: "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
add_foreign_key "vulnerability_feedback", "ci_pipelines", column: "pipeline_id", on_delete: :nullify
add_foreign_key "vulnerability_feedback", "issues", on_delete: :nullify
@@ -4393,6 +4558,8 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) do
add_foreign_key "vulnerability_feedback", "users", column: "author_id", on_delete: :cascade
add_foreign_key "vulnerability_feedback", "users", column: "comment_author_id", name: "fk_94f7c8a81e", on_delete: :nullify
add_foreign_key "vulnerability_identifiers", "projects", on_delete: :cascade
+ add_foreign_key "vulnerability_issue_links", "issues", on_delete: :cascade
+ add_foreign_key "vulnerability_issue_links", "vulnerabilities", on_delete: :cascade
add_foreign_key "vulnerability_occurrence_identifiers", "vulnerability_identifiers", column: "identifier_id", on_delete: :cascade
add_foreign_key "vulnerability_occurrence_identifiers", "vulnerability_occurrences", column: "occurrence_id", on_delete: :cascade
add_foreign_key "vulnerability_occurrence_pipelines", "ci_pipelines", column: "pipeline_id", on_delete: :cascade
@@ -4404,4 +4571,6 @@ ActiveRecord::Schema.define(version: 2019_10_26_041447) 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 "zoom_meetings", "issues", on_delete: :cascade
+ add_foreign_key "zoom_meetings", "projects", on_delete: :cascade
end