summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/01_admin.rb2
-rw-r--r--db/fixtures/development/02_users.rb3
-rw-r--r--db/fixtures/development/03_project.rb9
-rw-r--r--db/fixtures/development/06_teams.rb2
-rw-r--r--db/fixtures/development/07_milestones.rb2
-rw-r--r--db/fixtures/development/09_issues.rb2
-rw-r--r--db/fixtures/development/10_merge_requests.rb2
-rw-r--r--db/fixtures/development/11_keys.rb2
-rw-r--r--db/fixtures/development/12_snippets.rb2
-rw-r--r--db/fixtures/development/13_comments.rb2
-rw-r--r--db/fixtures/development/14_pipelines.rb2
-rw-r--r--db/fixtures/development/15_award_emoji.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/20_nested_groups.rb2
-rw-r--r--db/fixtures/development/21_dev_ops_score_metrics.rb (renamed from db/fixtures/development/21_conversational_development_index_metrics.rb)6
-rw-r--r--db/fixtures/development/24_forks.rb2
-rw-r--r--db/fixtures/development/25_api_personal_access_token.rb2
-rw-r--r--db/migrate/20180113220114_rework_redirect_routes_indexes.rb6
-rw-r--r--db/migrate/20180215181245_users_name_lower_index.rb4
-rw-r--r--db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb10
-rw-r--r--db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb2
-rw-r--r--db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb24
-rw-r--r--db/migrate/20180504195842_project_name_lower_index.rb4
-rw-r--r--db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb22
-rw-r--r--db/migrate/20180711103851_drop_duplicate_protected_tags.rb9
-rw-r--r--db/migrate/20180927073410_add_index_to_project_deploy_tokens_deploy_token_id.rb5
-rw-r--r--db/migrate/20190402150158_backport_enterprise_schema.rb3
-rw-r--r--db/migrate/20190606202100_add_name_to_badges.rb11
-rw-r--r--db/migrate/20190920122420_add_max_personal_access_token_lifetime_to_application_settings.rb9
-rw-r--r--db/migrate/20191003130045_create_issue_user_mentions.rb19
-rw-r--r--db/migrate/20191003150045_create_merge_request_user_mentions.rb19
-rw-r--r--db/migrate/20191003200045_create_epic_user_mentions.rb19
-rw-r--r--db/migrate/20191003250045_create_commit_user_mentions.rb18
-rw-r--r--db/migrate/20191003300045_create_snippet_user_mentions.rb19
-rw-r--r--db/migrate/20191003350045_create_design_user_mentions.rb19
-rw-r--r--db/migrate/20191004151428_add_auto_stop_in_to_environments.rb9
-rw-r--r--db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb17
-rw-r--r--db/migrate/20191023093207_add_comment_actions_to_services.rb17
-rw-r--r--db/migrate/20191025092748_add_secret_token_to_snippet.rb10
-rw-r--r--db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb16
-rw-r--r--db/migrate/20191026120112_add_promoted_to_epic_to_issues_index.rb22
-rw-r--r--db/migrate/20191028130054_add_max_issue_weight_to_list.rb17
-rw-r--r--db/migrate/20191105134413_create_service_desk_settings.rb18
-rw-r--r--db/migrate/20191105155113_add_secret_to_snippet.rb27
-rw-r--r--db/migrate/20191106144901_add_state_to_merge_trains.rb18
-rw-r--r--db/migrate/20191106150931_add_timelog_spent_at_index.rb20
-rw-r--r--db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb29
-rw-r--r--db/migrate/20191108031900_create_package_build_info.rb12
-rw-r--r--db/migrate/20191111175230_add_index_on_ci_pipelines_updated_at.rb18
-rw-r--r--db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb20
-rw-r--r--db/migrate/20191112105448_add_index_on_personal_access_tokens_user_id_and_expires_at.rb18
-rw-r--r--db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb9
-rw-r--r--db/migrate/20191115001123_add_index_to_mod_sec_ci_variables.rb17
-rw-r--r--db/migrate/20191115001843_add_index_to_mod_sec_ci_pipeline_variables.rb17
-rw-r--r--db/migrate/20191118053631_add_group_deletion_schedules.rb28
-rw-r--r--db/migrate/20191118155702_add_index_on_status_to_merge_trains.rb20
-rw-r--r--db/migrate/20191118173522_add_snippet_size_limit_to_application_settings.rb13
-rw-r--r--db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb21
-rw-r--r--db/migrate/20191119023952_add_created_at_index_to_snippets.rb17
-rw-r--r--db/migrate/20191119220425_rename_software_license_policies_approval_status_to_classification.rb17
-rw-r--r--db/migrate/20191119231621_create_container_expiration_policies.rb21
-rw-r--r--db/migrate/20191120200015_add_index_to_grafana_integrations.rb15
-rw-r--r--db/migrate/20191121111621_create_packages_dependencies.rb14
-rw-r--r--db/migrate/20191121121947_create_packages_dependency_links.rb15
-rw-r--r--db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb22
-rw-r--r--db/migrate/20191121193110_add_issue_links_type.rb17
-rw-r--r--db/migrate/20191122161519_create_sentry_issues_table.rb15
-rw-r--r--db/migrate/20191123062354_add_minimum_password_length_to_application_settings.rb11
-rw-r--r--db/migrate/20191124150431_change_label_id_index_to_include_action_on_label_events.rb21
-rw-r--r--db/migrate/20191125114345_add_admin_mode_protected_path.rb54
-rw-r--r--db/migrate/20191125133353_add_target_path_to_broadcast_message.rb9
-rw-r--r--db/migrate/20191125140458_create_import_failures.rb17
-rw-r--r--db/migrate/20191127030005_create_serverless_domain_cluster.rb17
-rw-r--r--db/migrate/20191127151619_create_gitlab_subscription_histories.rb28
-rw-r--r--db/migrate/20191127151629_add_trial_starts_on_to_gitlab_subscriptions.rb10
-rw-r--r--db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb20
-rw-r--r--db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb19
-rw-r--r--db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb13
-rw-r--r--db/migrate/20191203121729_update_group_deletion_schedules_foreign_keys.rb29
-rw-r--r--db/migrate/20191204070713_change_updated_at_index_and_add_index_to_id_on_deployments.rb29
-rw-r--r--db/migrate/20191204093410_add_label_project_group_partial_indexes.rb25
-rw-r--r--db/migrate/20191204192726_add_design_disk_path_to_geo_hashed_storage_migrated_events.rb12
-rw-r--r--db/migrate/20191205060723_add_index_to_keys.rb17
-rw-r--r--db/migrate/20191205094702_add_index_for_cross_projects_dependencies_to_ci_builds.rb19
-rw-r--r--db/migrate/20191205145647_add_index_to_projects_deploy_keys_deploy_key.rb17
-rw-r--r--db/migrate/20191206022133_add_indexes_to_pages_domains_on_wildcard_and_domain_type.rb19
-rw-r--r--db/migrate/20191206122926_update_index_for_pool_repositories.rb24
-rw-r--r--db/migrate/20191208071111_add_fingerprint_sha256_to_key.rb13
-rw-r--r--db/migrate/20191208071112_add_fingerprint_sha256_index_to_key.rb17
-rw-r--r--db/migrate/20191212140117_change_commit_user_mentions_commit_id_column_type.rb36
-rw-r--r--db/migrate/20191213104838_add_service_desk_username.rb9
-rw-r--r--db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb20
-rw-r--r--db/migrate/20191216094119_add_id_to_plan_limits.rb13
-rw-r--r--db/migrate/20191216183531_add_project_hooks_to_plan_limits.rb9
-rw-r--r--db/migrate/20191216183532_insert_project_hooks_plan_limits.rb25
-rw-r--r--db/optional_migrations/composite_primary_keys.rb4
-rw-r--r--db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb14
-rw-r--r--db/post_migrate/20180223124427_build_user_interacted_projects_table.rb32
-rw-r--r--db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb16
-rw-r--r--db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb2
-rw-r--r--db/post_migrate/20180706223200_populate_site_statistics.rb4
-rw-r--r--db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb2
-rw-r--r--db/post_migrate/20180826111825_recalculate_site_statistics.rb4
-rw-r--r--db/post_migrate/20191015154408_drop_merge_requests_require_code_owner_approval_from_projects.rb27
-rw-r--r--db/post_migrate/20191030223057_backfill_version_author_and_created_at.rb67
-rw-r--r--db/post_migrate/20191104142124_nullify_users_role.rb26
-rw-r--r--db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb14
-rw-r--r--db/post_migrate/20191108202723_add_unique_constraint_to_software_licenses.rb69
-rw-r--r--db/post_migrate/20191112023159_complete_pages_metadata_migration.rb13
-rw-r--r--db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb53
-rw-r--r--db/post_migrate/20191119221041_cleanup_software_license_policies_classification_rename.rb17
-rw-r--r--db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb16
-rw-r--r--db/post_migrate/20191125024005_cleanup_deploy_access_levels_for_removed_groups.rb32
-rw-r--r--db/post_migrate/20191202031812_drop_operations_feature_flags_clients_token.rb23
-rw-r--r--db/post_migrate/20191205084057_update_minimum_password_length.rb24
-rw-r--r--db/post_migrate/20191209215316_knative_0_9_prometheus_update.rb13
-rw-r--r--db/post_migrate/20191212162434_change_commit_user_mentions_commit_id_column_type_cleanup.rb25
-rw-r--r--db/schema.rb259
120 files changed, 1956 insertions, 190 deletions
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb
index 1e260236dc5..46b114dd07b 100644
--- a/db/fixtures/development/01_admin.rb
+++ b/db/fixtures/development/01_admin.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
User.create!(
diff --git a/db/fixtures/development/02_users.rb b/db/fixtures/development/02_users.rb
index 6e0b37d7258..909d10cbb40 100644
--- a/db/fixtures/development/02_users.rb
+++ b/db/fixtures/development/02_users.rb
@@ -5,7 +5,6 @@ class Gitlab::Seeder::Users
RANDOM_USERS_COUNT = 20
MASS_USERS_COUNT = ENV['CI'] ? 10 : 1_000_000
- MASS_INSERT_USERNAME_START = 'mass_insert_user_'
attr_reader :opts
@@ -29,7 +28,7 @@ class Gitlab::Seeder::Users
ActiveRecord::Base.connection.execute <<~SQL
INSERT INTO users (username, name, email, confirmed_at, projects_limit, encrypted_password)
SELECT
- '#{MASS_INSERT_USERNAME_START}' || seq,
+ '#{Gitlab::Seeder::MASS_INSERT_USER_START}' || seq,
'Seed user ' || seq,
'seed_user' || seq || '@example.com',
to_timestamp(seq),
diff --git a/db/fixtures/development/03_project.rb b/db/fixtures/development/03_project.rb
index 87ef65276eb..596c5e81a2e 100644
--- a/db/fixtures/development/03_project.rb
+++ b/db/fixtures/development/03_project.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
class Gitlab::Seeder::Projects
include ActionView::Helpers::NumberHelper
@@ -52,7 +52,6 @@ class Gitlab::Seeder::Projects
internal: 1, # 1m projects +
public: 1 # 1m projects = 5m total
}
- MASS_INSERT_NAME_START = 'mass_insert_project_'
def seed!
Sidekiq::Testing.inline! do
@@ -142,6 +141,10 @@ class Gitlab::Seeder::Projects
# 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)
+
+ # Expire repository cache after import to ensure
+ # valid_repo? call below returns a correct answer
+ project.repository.expire_all_method_caches
end
if project.valid? && project.valid_repo?
@@ -167,7 +170,7 @@ class Gitlab::Seeder::Projects
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,
+ '#{Gitlab::Seeder::MASS_INSERT_PROJECT_START}' || ('{#{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,
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index 79ea96bf30e..94d3aa59710 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/07_milestones.rb
index 1194bb3fe6f..8a282562335 100644
--- a/db/fixtures/development/07_milestones.rb
+++ b/db/fixtures/development/07_milestones.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
Project.not_mass_generated.each do |project|
diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb
index 582a5203d1d..7487a57fdb6 100644
--- a/db/fixtures/development/09_issues.rb
+++ b/db/fixtures/development/09_issues.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
Rake::Task["gitlab:seed:issues"].invoke
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 29f2fabbd5f..77650ebb1bc 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
# Limit the number of merge requests per project to avoid long seeds
diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb
index 13eadc35e07..eeee2388d01 100644
--- a/db/fixtures/development/11_keys.rb
+++ b/db/fixtures/development/11_keys.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
# Creating keys runs a gitlab-shell worker. Since we may not have the right
diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb
index 0ee9058a20b..3fa172c8f0f 100644
--- a/db/fixtures/development/12_snippets.rb
+++ b/db/fixtures/development/12_snippets.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
content =<<eos
diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb
index bc2d74c8034..8f63ca302c6 100644
--- a/db/fixtures/development/13_comments.rb
+++ b/db/fixtures/development/13_comments.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
Issue.find_each do |issue|
diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb
index 468caac23f9..4e9131c1a46 100644
--- a/db/fixtures/development/14_pipelines.rb
+++ b/db/fixtures/development/14_pipelines.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
class Gitlab::Seeder::Pipelines
STAGES = %w[build test deploy notify]
diff --git a/db/fixtures/development/15_award_emoji.rb b/db/fixtures/development/15_award_emoji.rb
index a9dcc048586..2b69a6c26ab 100644
--- a/db/fixtures/development/15_award_emoji.rb
+++ b/db/fixtures/development/15_award_emoji.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
EMOJI = Gitlab::Emoji.emojis.keys
diff --git a/db/fixtures/development/16_protected_branches.rb b/db/fixtures/development/16_protected_branches.rb
index 2b492ac1f61..e6615b20f9c 100644
--- a/db/fixtures/development/16_protected_branches.rb
+++ b/db/fixtures/development/16_protected_branches.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Gitlab::Seeder.quiet do
admin_user = User.find(1)
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb
index 606a4cb1dde..2532b71ad26 100644
--- a/db/fixtures/development/17_cycle_analytics.rb
+++ b/db/fixtures/development/17_cycle_analytics.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
require './spec/support/helpers/test_env'
class Gitlab::Seeder::CycleAnalytics
diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb
index 08363804216..124f9d74ddd 100644
--- a/db/fixtures/development/19_environments.rb
+++ b/db/fixtures/development/19_environments.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
class Gitlab::Seeder::Environments
def initialize(project)
diff --git a/db/fixtures/development/20_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb
index 3d95e243f8a..8f64dfbd644 100644
--- a/db/fixtures/development/20_nested_groups.rb
+++ b/db/fixtures/development/20_nested_groups.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
diff --git a/db/fixtures/development/21_conversational_development_index_metrics.rb b/db/fixtures/development/21_dev_ops_score_metrics.rb
index 4cd0a82ed1a..afea7fb4bd0 100644
--- a/db/fixtures/development/21_conversational_development_index_metrics.rb
+++ b/db/fixtures/development/21_dev_ops_score_metrics.rb
@@ -1,5 +1,5 @@
Gitlab::Seeder.quiet do
- conversational_development_index_metric = ConversationalDevelopmentIndex::Metric.new(
+ dev_ops_score_metric = DevOpsScore::Metric.new(
leader_issues: 10.2,
instance_issues: 3.2,
@@ -31,10 +31,10 @@ Gitlab::Seeder.quiet do
instance_service_desk_issues: 15.1
)
- if conversational_development_index_metric.save
+ if dev_ops_score_metric.save
print '.'
else
- puts conversational_development_index_metric.errors.full_messages
+ puts dev_ops_score_metric.errors.full_messages
print 'F'
end
end
diff --git a/db/fixtures/development/24_forks.rb b/db/fixtures/development/24_forks.rb
index fa16b2a1d93..cb6dbb7504d 100644
--- a/db/fixtures/development/24_forks.rb
+++ b/db/fixtures/development/24_forks.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
diff --git a/db/fixtures/development/25_api_personal_access_token.rb b/db/fixtures/development/25_api_personal_access_token.rb
index a2e6c674c1f..0a8fd86b440 100644
--- a/db/fixtures/development/25_api_personal_access_token.rb
+++ b/db/fixtures/development/25_api_personal_access_token.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require './spec/support/sidekiq'
+require './spec/support/sidekiq_middleware'
# Create an api access token for root user with the value: ypCa3Dzb23o5nvsixwPA
Gitlab::Seeder.quiet do
diff --git a/db/migrate/20180113220114_rework_redirect_routes_indexes.rb b/db/migrate/20180113220114_rework_redirect_routes_indexes.rb
index 2b9365ce827..ca7ce6286dc 100644
--- a/db/migrate/20180113220114_rework_redirect_routes_indexes.rb
+++ b/db/migrate/20180113220114_rework_redirect_routes_indexes.rb
@@ -25,10 +25,6 @@ class ReworkRedirectRoutesIndexes < ActiveRecord::Migration[4.2]
remove_concurrent_index(:redirect_routes, :permanent)
end
- # If we're on MySQL then the existing index on path is ok. But on
- # Postgres we need to clean things up:
- break unless Gitlab::Database.postgresql?
-
if_not_exists = Gitlab::Database.version.to_f >= 9.5 ? "IF NOT EXISTS" : ""
# Unique index on lower(path) across both types of redirect_routes:
@@ -53,8 +49,6 @@ class ReworkRedirectRoutesIndexes < ActiveRecord::Migration[4.2]
disable_statement_timeout do
add_concurrent_index(:redirect_routes, :permanent)
- break unless Gitlab::Database.postgresql?
-
execute("CREATE INDEX CONCURRENTLY #{OLD_INDEX_NAME_PATH_TPOPS} ON redirect_routes (path varchar_pattern_ops);")
execute("CREATE INDEX CONCURRENTLY #{OLD_INDEX_NAME_PATH_LOWER} ON redirect_routes (LOWER(path));")
diff --git a/db/migrate/20180215181245_users_name_lower_index.rb b/db/migrate/20180215181245_users_name_lower_index.rb
index fa1a115a78a..46f02885c3f 100644
--- a/db/migrate/20180215181245_users_name_lower_index.rb
+++ b/db/migrate/20180215181245_users_name_lower_index.rb
@@ -11,15 +11,11 @@ class UsersNameLowerIndex < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- return unless Gitlab::Database.postgresql?
-
# On GitLab.com this produces an index with a size of roughly 60 MB.
execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON users (LOWER(name))"
end
def down
- return unless Gitlab::Database.postgresql?
-
execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
end
end
diff --git a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
index 4d2ab7d757f..58a1d2b12d5 100644
--- a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
+++ b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
@@ -8,16 +8,10 @@ class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- # MySQL may already have this as a foreign key
- unless index_exists?(:ci_build_trace_sections, :section_name_id, name: INDEX_NAME)
- add_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
- end
+ add_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
end
def down
- # We cannot remove index for MySQL because it's needed for foreign key
- if Gitlab::Database.postgresql?
- remove_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
- end
+ remove_concurrent_index :ci_build_trace_sections, :section_name_id, name: INDEX_NAME
end
end
diff --git a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb
index ecb06dd4312..3d85a19b82f 100644
--- a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb
+++ b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb
@@ -18,7 +18,7 @@ class RescheduleCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2]
def up
say 'Populating the MergeRequestDiff `commits_count` (reschedule)'
- execute("SET statement_timeout TO '60s'") if Gitlab::Database.postgresql?
+ execute("SET statement_timeout TO '60s'")
MergeRequestDiff.where(commits_count: nil).each_batch(of: BATCH_SIZE) do |relation, index|
start_id, end_id = relation.pluck('MIN(id), MAX(id)').first
diff --git a/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb b/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb
index a15e1d68a95..ba8ad1b7495 100644
--- a/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb
+++ b/db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb
@@ -13,28 +13,6 @@ class AddIndexesForUserActivityQueries < ActiveRecord::Migration[4.2]
def down
remove_concurrent_index :events, [:author_id, :project_id] if index_exists?(:events, [:author_id, :project_id])
- patch_foreign_keys do
- remove_concurrent_index :user_interacted_projects, :user_id if index_exists?(:user_interacted_projects, :user_id)
- end
- end
-
- private
-
- def patch_foreign_keys
- return yield if Gitlab::Database.postgresql?
-
- # MySQL doesn't like to remove the index with a foreign key using it.
- remove_foreign_key :user_interacted_projects, :users if fk_exists?(:user_interacted_projects, :user_id)
-
- yield
-
- # Let's re-add the foreign key using the existing index on (user_id, project_id)
- add_concurrent_foreign_key :user_interacted_projects, :users, column: :user_id unless fk_exists?(:user_interacted_projects, :user_id)
- end
-
- def fk_exists?(table, column)
- foreign_keys(table).any? do |key|
- key.options[:column] == column.to_s
- end
+ remove_concurrent_index :user_interacted_projects, :user_id if index_exists?(:user_interacted_projects, :user_id)
end
end
diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb
index fa74330d5d9..e789837193f 100644
--- a/db/migrate/20180504195842_project_name_lower_index.rb
+++ b/db/migrate/20180504195842_project_name_lower_index.rb
@@ -11,16 +11,12 @@ class ProjectNameLowerIndex < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- return unless Gitlab::Database.postgresql?
-
disable_statement_timeout do
execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON projects (LOWER(name))"
end
end
def down
- return unless Gitlab::Database.postgresql?
-
disable_statement_timeout do
execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
end
diff --git a/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb b/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb
index 36f4770ff32..859e341d04b 100644
--- a/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb
+++ b/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb
@@ -5,34 +5,20 @@ class AddNotNullConstraintsToProjectAuthorizations < ActiveRecord::Migration[4.2
DOWNTIME = false
def up
- if Gitlab::Database.postgresql?
- # One-pass version for PostgreSQL
- execute <<~SQL
+ execute <<~SQL
ALTER TABLE project_authorizations
ALTER COLUMN user_id SET NOT NULL,
ALTER COLUMN project_id SET NOT NULL,
ALTER COLUMN access_level SET NOT NULL
- SQL
- else
- change_column_null :project_authorizations, :user_id, false
- change_column_null :project_authorizations, :project_id, false
- change_column_null :project_authorizations, :access_level, false
- end
+ SQL
end
def down
- if Gitlab::Database.postgresql?
- # One-pass version for PostgreSQL
- execute <<~SQL
+ execute <<~SQL
ALTER TABLE project_authorizations
ALTER COLUMN user_id DROP NOT NULL,
ALTER COLUMN project_id DROP NOT NULL,
ALTER COLUMN access_level DROP NOT NULL
- SQL
- else
- change_column_null :project_authorizations, :user_id, true
- change_column_null :project_authorizations, :project_id, true
- change_column_null :project_authorizations, :access_level, true
- end
+ SQL
end
end
diff --git a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb
index 6166aa65f1f..94f72aa162d 100644
--- a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb
+++ b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb
@@ -29,14 +29,7 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration[4.2]
.where(project_id: projects)
.where.not(id: ids)
- if Gitlab::Database.postgresql?
- tags.delete_all
- else
- # Workaround needed for MySQL
- sql = "SELECT id FROM (#{tags.to_sql}) protected_tags"
-
- ProtectedTag.where("id IN (#{sql})").delete_all # rubocop:disable GitlabSecurity/SqlInjection
- end
+ tags.delete_all
end
end
diff --git a/db/migrate/20180927073410_add_index_to_project_deploy_tokens_deploy_token_id.rb b/db/migrate/20180927073410_add_index_to_project_deploy_tokens_deploy_token_id.rb
index 80577c52a01..edfcad81202 100644
--- a/db/migrate/20180927073410_add_index_to_project_deploy_tokens_deploy_token_id.rb
+++ b/db/migrate/20180927073410_add_index_to_project_deploy_tokens_deploy_token_id.rb
@@ -8,11 +8,10 @@ class AddIndexToProjectDeployTokensDeployTokenId < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- # MySQL already has index inserted
- add_concurrent_index :project_deploy_tokens, :deploy_token_id if Gitlab::Database.postgresql?
+ add_concurrent_index :project_deploy_tokens, :deploy_token_id
end
def down
- remove_concurrent_index(:project_deploy_tokens, :deploy_token_id) if Gitlab::Database.postgresql?
+ remove_concurrent_index(:project_deploy_tokens, :deploy_token_id)
end
end
diff --git a/db/migrate/20190402150158_backport_enterprise_schema.rb b/db/migrate/20190402150158_backport_enterprise_schema.rb
index 3f13b68c2f3..d1e911a04e6 100644
--- a/db/migrate/20190402150158_backport_enterprise_schema.rb
+++ b/db/migrate/20190402150158_backport_enterprise_schema.rb
@@ -464,15 +464,12 @@ class BackportEnterpriseSchema < ActiveRecord::Migration[5.0]
end
def update_environments
- return unless Gitlab::Database.postgresql?
return if index_exists?(:environments, :name, name: 'index_environments_on_name_varchar_pattern_ops')
execute('CREATE INDEX CONCURRENTLY index_environments_on_name_varchar_pattern_ops ON environments (name varchar_pattern_ops);')
end
def revert_environments
- return unless Gitlab::Database.postgresql?
-
remove_concurrent_index_by_name(
:environments,
'index_environments_on_name_varchar_pattern_ops'
diff --git a/db/migrate/20190606202100_add_name_to_badges.rb b/db/migrate/20190606202100_add_name_to_badges.rb
new file mode 100644
index 00000000000..472e1202ad8
--- /dev/null
+++ b/db/migrate/20190606202100_add_name_to_badges.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddNameToBadges < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :badges, :name, :string, null: true, limit: 255
+ end
+end
diff --git a/db/migrate/20190920122420_add_max_personal_access_token_lifetime_to_application_settings.rb b/db/migrate/20190920122420_add_max_personal_access_token_lifetime_to_application_settings.rb
new file mode 100644
index 00000000000..5a6e810dede
--- /dev/null
+++ b/db/migrate/20190920122420_add_max_personal_access_token_lifetime_to_application_settings.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddMaxPersonalAccessTokenLifetimeToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :application_settings, :max_personal_access_token_lifetime, :integer
+ end
+end
diff --git a/db/migrate/20191003130045_create_issue_user_mentions.rb b/db/migrate/20191003130045_create_issue_user_mentions.rb
new file mode 100644
index 00000000000..e465a307f44
--- /dev/null
+++ b/db/migrate/20191003130045_create_issue_user_mentions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateIssueUserMentions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :issue_user_mentions do |t|
+ t.references :issue, type: :integer, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.references :note, type: :integer,
+ index: { where: 'note_id IS NOT NULL', unique: true }, null: true, foreign_key: { on_delete: :cascade }
+ t.integer :mentioned_users_ids, array: true
+ t.integer :mentioned_projects_ids, array: true
+ t.integer :mentioned_groups_ids, array: true
+ end
+
+ add_index :issue_user_mentions, [:issue_id], where: 'note_id is null', unique: true, name: 'issue_user_mentions_on_issue_id_index'
+ add_index :issue_user_mentions, [:issue_id, :note_id], unique: true, name: 'issue_user_mentions_on_issue_id_and_note_id_index'
+ end
+end
diff --git a/db/migrate/20191003150045_create_merge_request_user_mentions.rb b/db/migrate/20191003150045_create_merge_request_user_mentions.rb
new file mode 100644
index 00000000000..0ec45020127
--- /dev/null
+++ b/db/migrate/20191003150045_create_merge_request_user_mentions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateMergeRequestUserMentions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :merge_request_user_mentions do |t|
+ t.references :merge_request, type: :integer, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.references :note, type: :integer,
+ index: { where: 'note_id IS NOT NULL', unique: true }, null: true, foreign_key: { on_delete: :cascade }
+ t.integer :mentioned_users_ids, array: true
+ t.integer :mentioned_projects_ids, array: true
+ t.integer :mentioned_groups_ids, array: true
+ end
+
+ add_index :merge_request_user_mentions, [:merge_request_id], where: 'note_id is null', unique: true, name: 'merge_request_user_mentions_on_mr_id_index'
+ add_index :merge_request_user_mentions, [:merge_request_id, :note_id], unique: true, name: 'merge_request_user_mentions_on_mr_id_and_note_id_index'
+ end
+end
diff --git a/db/migrate/20191003200045_create_epic_user_mentions.rb b/db/migrate/20191003200045_create_epic_user_mentions.rb
new file mode 100644
index 00000000000..25f9b24f9cc
--- /dev/null
+++ b/db/migrate/20191003200045_create_epic_user_mentions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateEpicUserMentions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :epic_user_mentions do |t|
+ t.references :epic, type: :integer, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.references :note, type: :integer,
+ index: { where: 'note_id IS NOT NULL', unique: true }, null: true, foreign_key: { on_delete: :cascade }
+ t.integer :mentioned_users_ids, array: true
+ t.integer :mentioned_projects_ids, array: true
+ t.integer :mentioned_groups_ids, array: true
+ end
+
+ add_index :epic_user_mentions, [:epic_id], where: 'note_id is null', unique: true, name: 'epic_user_mentions_on_epic_id_index'
+ add_index :epic_user_mentions, [:epic_id, :note_id], unique: true, name: 'epic_user_mentions_on_epic_id_and_note_id_index'
+ end
+end
diff --git a/db/migrate/20191003250045_create_commit_user_mentions.rb b/db/migrate/20191003250045_create_commit_user_mentions.rb
new file mode 100644
index 00000000000..135c115c725
--- /dev/null
+++ b/db/migrate/20191003250045_create_commit_user_mentions.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateCommitUserMentions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :commit_user_mentions do |t|
+ t.references :note, type: :integer,
+ index: { unique: true }, null: false, foreign_key: { on_delete: :cascade }
+ t.binary :commit_id, null: false
+ t.integer :mentioned_users_ids, array: true
+ t.integer :mentioned_projects_ids, array: true
+ t.integer :mentioned_groups_ids, array: true
+ end
+
+ add_index :commit_user_mentions, [:commit_id, :note_id], name: 'commit_user_mentions_on_commit_id_and_note_id_index'
+ end
+end
diff --git a/db/migrate/20191003300045_create_snippet_user_mentions.rb b/db/migrate/20191003300045_create_snippet_user_mentions.rb
new file mode 100644
index 00000000000..fb7681d6e33
--- /dev/null
+++ b/db/migrate/20191003300045_create_snippet_user_mentions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateSnippetUserMentions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :snippet_user_mentions do |t|
+ t.references :snippet, type: :integer, index: false, null: false, foreign_key: { on_delete: :cascade }
+ t.references :note, type: :integer,
+ index: { where: 'note_id IS NOT NULL', unique: true }, null: true, foreign_key: { on_delete: :cascade }
+ t.integer :mentioned_users_ids, array: true
+ t.integer :mentioned_projects_ids, array: true
+ t.integer :mentioned_groups_ids, array: true
+ end
+
+ add_index :snippet_user_mentions, [:snippet_id], where: 'note_id is null', unique: true, name: 'snippet_user_mentions_on_snippet_id_index'
+ add_index :snippet_user_mentions, [:snippet_id, :note_id], unique: true, name: 'snippet_user_mentions_on_snippet_id_and_note_id_index'
+ end
+end
diff --git a/db/migrate/20191003350045_create_design_user_mentions.rb b/db/migrate/20191003350045_create_design_user_mentions.rb
new file mode 100644
index 00000000000..149ee5bd124
--- /dev/null
+++ b/db/migrate/20191003350045_create_design_user_mentions.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class CreateDesignUserMentions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :design_user_mentions do |t|
+ t.references :design, type: :integer, index: false, null: false,
+ foreign_key: { to_table: :design_management_designs, column: :design_id, on_delete: :cascade }
+ t.references :note, type: :integer,
+ index: { unique: true }, null: false, foreign_key: { on_delete: :cascade }
+ t.integer :mentioned_users_ids, array: true
+ t.integer :mentioned_projects_ids, array: true
+ t.integer :mentioned_groups_ids, array: true
+ end
+
+ add_index :design_user_mentions, [:design_id, :note_id], name: 'design_user_mentions_on_design_id_and_note_id_index'
+ end
+end
diff --git a/db/migrate/20191004151428_add_auto_stop_in_to_environments.rb b/db/migrate/20191004151428_add_auto_stop_in_to_environments.rb
new file mode 100644
index 00000000000..860e52d420c
--- /dev/null
+++ b/db/migrate/20191004151428_add_auto_stop_in_to_environments.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddAutoStopInToEnvironments < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :environments, :auto_stop_at, :datetime_with_timezone
+ end
+end
diff --git a/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb b/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb
new file mode 100644
index 00000000000..f172d3bdcbd
--- /dev/null
+++ b/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddExpireNotificationDeliveredToPersonalAccessTokens < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :personal_access_tokens, :expire_notification_delivered, :boolean, default: false
+ end
+
+ def down
+ remove_column :personal_access_tokens, :expire_notification_delivered
+ end
+end
diff --git a/db/migrate/20191023093207_add_comment_actions_to_services.rb b/db/migrate/20191023093207_add_comment_actions_to_services.rb
new file mode 100644
index 00000000000..f3fc12ac7c7
--- /dev/null
+++ b/db/migrate/20191023093207_add_comment_actions_to_services.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddCommentActionsToServices < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:services, :comment_on_event_enabled, :boolean, default: true)
+ end
+
+ def down
+ remove_column(:services, :comment_on_event_enabled)
+ end
+end
diff --git a/db/migrate/20191025092748_add_secret_token_to_snippet.rb b/db/migrate/20191025092748_add_secret_token_to_snippet.rb
new file mode 100644
index 00000000000..0649f58d23e
--- /dev/null
+++ b/db/migrate/20191025092748_add_secret_token_to_snippet.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddSecretTokenToSnippet < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :snippets, :encrypted_secret_token, :string, limit: 255
+ add_column :snippets, :encrypted_secret_token_iv, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb b/db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb
new file mode 100644
index 00000000000..158dbf69bcc
--- /dev/null
+++ b/db/migrate/20191026120008_add_promoted_to_epic_to_issues.rb
@@ -0,0 +1,16 @@
+# 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 AddPromotedToEpicToIssues < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :issues, :promoted_to_epic_id, :integer
+ end
+
+ def down
+ remove_column :issues, :promoted_to_epic_id
+ end
+end
diff --git a/db/migrate/20191026120112_add_promoted_to_epic_to_issues_index.rb b/db/migrate/20191026120112_add_promoted_to_epic_to_issues_index.rb
new file mode 100644
index 00000000000..649c2f7abe5
--- /dev/null
+++ b/db/migrate/20191026120112_add_promoted_to_epic_to_issues_index.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 AddPromotedToEpicToIssuesIndex < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :issues, :epics, column: :promoted_to_epic_id, on_delete: :nullify
+ add_concurrent_index :issues, :promoted_to_epic_id, where: 'promoted_to_epic_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index(:issues, :promoted_to_epic_id)
+ remove_foreign_key :issues, column: :promoted_to_epic_id
+ end
+end
diff --git a/db/migrate/20191028130054_add_max_issue_weight_to_list.rb b/db/migrate/20191028130054_add_max_issue_weight_to_list.rb
new file mode 100644
index 00000000000..eec7c42c907
--- /dev/null
+++ b/db/migrate/20191028130054_add_max_issue_weight_to_list.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddMaxIssueWeightToList < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ add_column_with_default :lists, :max_issue_weight, :integer, default: 0
+ end
+
+ def down
+ remove_column :lists, :max_issue_weight
+ end
+end
diff --git a/db/migrate/20191105134413_create_service_desk_settings.rb b/db/migrate/20191105134413_create_service_desk_settings.rb
new file mode 100644
index 00000000000..ee026b6f26d
--- /dev/null
+++ b/db/migrate/20191105134413_create_service_desk_settings.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class CreateServiceDeskSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :service_desk_settings, id: false do |t|
+ t.references :project,
+ primary_key: true,
+ default: nil,
+ null: false,
+ index: false,
+ foreign_key: { on_delete: :cascade }
+
+ t.string :issue_template_key, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20191105155113_add_secret_to_snippet.rb b/db/migrate/20191105155113_add_secret_to_snippet.rb
new file mode 100644
index 00000000000..ae514d48494
--- /dev/null
+++ b/db/migrate/20191105155113_add_secret_to_snippet.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class AddSecretToSnippet < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:snippets, :secret)
+ add_column_with_default :snippets, :secret, :boolean, default: false
+ end
+
+ add_concurrent_index :snippets, [:visibility_level, :secret]
+ remove_concurrent_index :snippets, :visibility_level
+ end
+
+ def down
+ add_concurrent_index :snippets, :visibility_level
+ remove_concurrent_index :snippets, [:visibility_level, :secret]
+
+ if column_exists?(:snippets, :secret)
+ remove_column :snippets, :secret
+ end
+ end
+end
diff --git a/db/migrate/20191106144901_add_state_to_merge_trains.rb b/db/migrate/20191106144901_add_state_to_merge_trains.rb
new file mode 100644
index 00000000000..e2256705f53
--- /dev/null
+++ b/db/migrate/20191106144901_add_state_to_merge_trains.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddStateToMergeTrains < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ MERGE_TRAIN_STATUS_CREATED = 0 # Equivalent to MergeTrain.statuses[:created]
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :merge_trains, :status, :integer, limit: 2, default: MERGE_TRAIN_STATUS_CREATED
+ end
+
+ def down
+ remove_column :merge_trains, :status
+ end
+end
diff --git a/db/migrate/20191106150931_add_timelog_spent_at_index.rb b/db/migrate/20191106150931_add_timelog_spent_at_index.rb
new file mode 100644
index 00000000000..2412b77d0bf
--- /dev/null
+++ b/db/migrate/20191106150931_add_timelog_spent_at_index.rb
@@ -0,0 +1,20 @@
+# 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 AddTimelogSpentAtIndex < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :timelogs, :spent_at, where: 'spent_at IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :timelogs, :spent_at, where: 'spent_at IS NOT NULL'
+ end
+end
diff --git a/db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb b/db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb
new file mode 100644
index 00000000000..439610758a6
--- /dev/null
+++ b/db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class UpdateOauthOpenIdRequestsForeignKeys < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(:oauth_openid_requests, :oauth_access_grants, column: :access_grant_id, on_delete: :cascade, name: new_foreign_key_name)
+ remove_foreign_key_if_exists(:oauth_openid_requests, name: existing_foreign_key_name)
+ end
+
+ def down
+ add_concurrent_foreign_key(:oauth_openid_requests, :oauth_access_grants, column: :access_grant_id, on_delete: false, name: existing_foreign_key_name)
+ remove_foreign_key_if_exists(:oauth_openid_requests, name: new_foreign_key_name)
+ end
+
+ private
+
+ def new_foreign_key_name
+ concurrent_foreign_key_name(:oauth_openid_requests, :access_grant_id)
+ end
+
+ def existing_foreign_key_name
+ 'fk_oauth_openid_requests_oauth_access_grants_access_grant_id'
+ end
+end
diff --git a/db/migrate/20191108031900_create_package_build_info.rb b/db/migrate/20191108031900_create_package_build_info.rb
new file mode 100644
index 00000000000..d0c85e2fb3f
--- /dev/null
+++ b/db/migrate/20191108031900_create_package_build_info.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class CreatePackageBuildInfo < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :packages_build_infos do |t|
+ t.references :package, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer, index: { unique: true }
+ t.references :pipeline, index: true, null: true, foreign_key: { to_table: :ci_pipelines, on_delete: :nullify }, type: :integer
+ end
+ end
+end
diff --git a/db/migrate/20191111175230_add_index_on_ci_pipelines_updated_at.rb b/db/migrate/20191111175230_add_index_on_ci_pipelines_updated_at.rb
new file mode 100644
index 00000000000..566bb16ac65
--- /dev/null
+++ b/db/migrate/20191111175230_add_index_on_ci_pipelines_updated_at.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnCiPipelinesUpdatedAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_COLUMNS = [:project_id, :status, :updated_at]
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:ci_pipelines, INDEX_COLUMNS)
+ end
+
+ def down
+ remove_concurrent_index(:ci_pipelines, INDEX_COLUMNS)
+ end
+end
diff --git a/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb b/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb
new file mode 100644
index 00000000000..2fbd003b2e5
--- /dev/null
+++ b/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddArtifactsToCiBuildNeed < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:ci_build_needs, :artifacts,
+ :boolean,
+ default: true,
+ allow_null: false)
+ end
+
+ def down
+ remove_column(:ci_build_needs, :artifacts)
+ end
+end
diff --git a/db/migrate/20191112105448_add_index_on_personal_access_tokens_user_id_and_expires_at.rb b/db/migrate/20191112105448_add_index_on_personal_access_tokens_user_id_and_expires_at.rb
new file mode 100644
index 00000000000..1c1dc31ff23
--- /dev/null
+++ b/db/migrate/20191112105448_add_index_on_personal_access_tokens_user_id_and_expires_at.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnPersonalAccessTokensUserIdAndExpiresAt < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_pat_on_user_id_and_expires_at'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :personal_access_tokens, [:user_id, :expires_at], name: INDEX_NAME, using: :btree
+ end
+
+ def down
+ remove_concurrent_index_by_name :personal_access_tokens, INDEX_NAME
+ end
+end
diff --git a/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb b/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb
new file mode 100644
index 00000000000..dbd69568ef2
--- /dev/null
+++ b/db/migrate/20191114132259_add_mentions_disabled_to_namespaces.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddMentionsDisabledToNamespaces < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :namespaces, :mentions_disabled, :boolean
+ end
+end
diff --git a/db/migrate/20191115001123_add_index_to_mod_sec_ci_variables.rb b/db/migrate/20191115001123_add_index_to_mod_sec_ci_variables.rb
new file mode 100644
index 00000000000..169ecf5ea41
--- /dev/null
+++ b/db/migrate/20191115001123_add_index_to_mod_sec_ci_variables.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToModSecCiVariables < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_variables, :project_id, where: "key = 'AUTO_DEVOPS_MODSECURITY_SEC_RULE_ENGINE'"
+ end
+
+ def down
+ remove_concurrent_index :ci_variables, :project_id
+ end
+end
diff --git a/db/migrate/20191115001843_add_index_to_mod_sec_ci_pipeline_variables.rb b/db/migrate/20191115001843_add_index_to_mod_sec_ci_pipeline_variables.rb
new file mode 100644
index 00000000000..6b13f565a11
--- /dev/null
+++ b/db/migrate/20191115001843_add_index_to_mod_sec_ci_pipeline_variables.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToModSecCiPipelineVariables < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_pipeline_variables, :pipeline_id, where: "key = 'AUTO_DEVOPS_MODSECURITY_SEC_RULE_ENGINE'"
+ end
+
+ def down
+ remove_concurrent_index :ci_pipeline_variables, :pipeline_id
+ end
+end
diff --git a/db/migrate/20191118053631_add_group_deletion_schedules.rb b/db/migrate/20191118053631_add_group_deletion_schedules.rb
new file mode 100644
index 00000000000..6f3ed27e156
--- /dev/null
+++ b/db/migrate/20191118053631_add_group_deletion_schedules.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class AddGroupDeletionSchedules < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ create_table :group_deletion_schedules, id: false do |t|
+ t.references :group,
+ foreign_key: { on_delete: :cascade, to_table: :namespaces },
+ default: nil,
+ index: false,
+ primary_key: true
+
+ t.references :user,
+ index: true,
+ foreign_key: { on_delete: :nullify },
+ null: false
+
+ t.date :marked_for_deletion_on,
+ index: true,
+ null: false
+ end
+ end
+
+ def down
+ drop_table :group_deletion_schedules
+ end
+end
diff --git a/db/migrate/20191118155702_add_index_on_status_to_merge_trains.rb b/db/migrate/20191118155702_add_index_on_status_to_merge_trains.rb
new file mode 100644
index 00000000000..9b5238045f8
--- /dev/null
+++ b/db/migrate/20191118155702_add_index_on_status_to_merge_trains.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddIndexOnStatusToMergeTrains < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_for_status_per_branch_per_project'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_trains, [:target_project_id, :target_branch, :status], name: INDEX_NAME
+ remove_concurrent_index :merge_trains, :target_project_id
+ end
+
+ def down
+ add_concurrent_index :merge_trains, :target_project_id
+ remove_concurrent_index :merge_trains, [:target_project_id, :target_branch, :status], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20191118173522_add_snippet_size_limit_to_application_settings.rb b/db/migrate/20191118173522_add_snippet_size_limit_to_application_settings.rb
new file mode 100644
index 00000000000..b6b30febbd6
--- /dev/null
+++ b/db/migrate/20191118173522_add_snippet_size_limit_to_application_settings.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddSnippetSizeLimitToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :application_settings, :snippet_size_limit, :bigint, default: 50.megabytes, null: false
+ end
+
+ def down
+ remove_column :application_settings, :snippet_size_limit
+ end
+end
diff --git a/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb b/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb
new file mode 100644
index 00000000000..b88a1f01d79
--- /dev/null
+++ b/db/migrate/20191118182722_add_index_to_environments_on_project_id_state_environment_type.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddIndexToEnvironmentsOnProjectIdStateEnvironmentType < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ OLD_INDEX_NAME = 'index_environments_on_project_id_and_state'.freeze
+ NEW_INDEX_NAME = 'index_environments_on_project_id_state_environment_type'.freeze
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:environments, [:project_id, :state, :environment_type], name: NEW_INDEX_NAME)
+ remove_concurrent_index_by_name(:environments, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:environments, [:project_id, :state], name: OLD_INDEX_NAME)
+ remove_concurrent_index_by_name(:environments, NEW_INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20191119023952_add_created_at_index_to_snippets.rb b/db/migrate/20191119023952_add_created_at_index_to_snippets.rb
new file mode 100644
index 00000000000..226af5f9e6d
--- /dev/null
+++ b/db/migrate/20191119023952_add_created_at_index_to_snippets.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddCreatedAtIndexToSnippets < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :snippets, :created_at
+ end
+
+ def down
+ remove_concurrent_index :snippets, :created_at
+ end
+end
diff --git a/db/migrate/20191119220425_rename_software_license_policies_approval_status_to_classification.rb b/db/migrate/20191119220425_rename_software_license_policies_approval_status_to_classification.rb
new file mode 100644
index 00000000000..98c14f42558
--- /dev/null
+++ b/db/migrate/20191119220425_rename_software_license_policies_approval_status_to_classification.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class RenameSoftwareLicensePoliciesApprovalStatusToClassification < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ rename_column_concurrently :software_license_policies, :approval_status, :classification
+ end
+
+ def down
+ undo_rename_column_concurrently :software_license_policies, :approval_status, :classification
+ end
+end
diff --git a/db/migrate/20191119231621_create_container_expiration_policies.rb b/db/migrate/20191119231621_create_container_expiration_policies.rb
new file mode 100644
index 00000000000..d7108870cf1
--- /dev/null
+++ b/db/migrate/20191119231621_create_container_expiration_policies.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class CreateContainerExpirationPolicies < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :container_expiration_policies, id: false, primary_key: :project_id do |t|
+ t.timestamps_with_timezone null: false
+ t.datetime_with_timezone :next_run_at
+ t.references :project, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade }
+ t.string :name_regex, limit: 255
+ t.string :cadence, null: false, limit: 12, default: '7d'
+ t.string :older_than, limit: 12
+ t.integer :keep_n
+ t.boolean :enabled, null: false, default: false
+ end
+
+ add_index :container_expiration_policies, [:next_run_at, :enabled],
+ name: 'index_container_expiration_policies_on_next_run_at_and_enabled'
+ end
+end
diff --git a/db/migrate/20191120200015_add_index_to_grafana_integrations.rb b/db/migrate/20191120200015_add_index_to_grafana_integrations.rb
new file mode 100644
index 00000000000..87292c86e97
--- /dev/null
+++ b/db/migrate/20191120200015_add_index_to_grafana_integrations.rb
@@ -0,0 +1,15 @@
+class AddIndexToGrafanaIntegrations < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :grafana_integrations, :enabled, where: 'enabled IS TRUE'
+ end
+
+ def down
+ remove_concurrent_index :grafana_integrations, :enabled
+ end
+end
diff --git a/db/migrate/20191121111621_create_packages_dependencies.rb b/db/migrate/20191121111621_create_packages_dependencies.rb
new file mode 100644
index 00000000000..61e52627b05
--- /dev/null
+++ b/db/migrate/20191121111621_create_packages_dependencies.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class CreatePackagesDependencies < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :packages_dependencies do |t|
+ t.string :name, null: false, limit: 255
+ t.string :version_pattern, null: false, limit: 255
+ end
+
+ add_index :packages_dependencies, [:name, :version_pattern], unique: true
+ end
+end
diff --git a/db/migrate/20191121121947_create_packages_dependency_links.rb b/db/migrate/20191121121947_create_packages_dependency_links.rb
new file mode 100644
index 00000000000..0907ed8f16c
--- /dev/null
+++ b/db/migrate/20191121121947_create_packages_dependency_links.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreatePackagesDependencyLinks < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :packages_dependency_links do |t|
+ t.references :package, index: false, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
+ t.references :dependency, null: false, foreign_key: { to_table: :packages_dependencies, on_delete: :cascade }, type: :bigint
+ t.integer :dependency_type, limit: 2, null: false
+ end
+
+ add_index :packages_dependency_links, [:package_id, :dependency_id, :dependency_type], unique: true, name: 'idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type'
+ end
+end
diff --git a/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb b/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb
new file mode 100644
index 00000000000..4511a2a0e49
--- /dev/null
+++ b/db/migrate/20191121161018_add_project_id_name_version_package_type_index_to_packages_packages.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddProjectIdNameVersionPackageTypeIndexToPackagesPackages < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'idx_packages_packages_on_project_id_name_version_package_type'.freeze
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :packages_packages,
+ [:project_id, :name, :version, :package_type],
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :packages_packages,
+ [:project_id, :name, :version, :package_type],
+ name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20191121193110_add_issue_links_type.rb b/db/migrate/20191121193110_add_issue_links_type.rb
new file mode 100644
index 00000000000..61ef2e7d7e8
--- /dev/null
+++ b/db/migrate/20191121193110_add_issue_links_type.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIssueLinksType < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :issue_links, :link_type, :integer, default: 0, limit: 2
+ end
+
+ def down
+ remove_column :issue_links, :link_type
+ end
+end
diff --git a/db/migrate/20191122161519_create_sentry_issues_table.rb b/db/migrate/20191122161519_create_sentry_issues_table.rb
new file mode 100644
index 00000000000..753286b6025
--- /dev/null
+++ b/db/migrate/20191122161519_create_sentry_issues_table.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class CreateSentryIssuesTable < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :sentry_issues do |t|
+ t.references :issue,
+ foreign_key: { on_delete: :cascade },
+ index: { unique: true },
+ null: false
+ t.bigint :sentry_issue_identifier, null: false
+ end
+ end
+end
diff --git a/db/migrate/20191123062354_add_minimum_password_length_to_application_settings.rb b/db/migrate/20191123062354_add_minimum_password_length_to_application_settings.rb
new file mode 100644
index 00000000000..0a7ad9d81a9
--- /dev/null
+++ b/db/migrate/20191123062354_add_minimum_password_length_to_application_settings.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class AddMinimumPasswordLengthToApplicationSettings < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ DEFAULT_MINIMUM_PASSWORD_LENGTH = 8
+
+ def change
+ add_column(:application_settings, :minimum_password_length, :integer, default: DEFAULT_MINIMUM_PASSWORD_LENGTH, null: false)
+ end
+end
diff --git a/db/migrate/20191124150431_change_label_id_index_to_include_action_on_label_events.rb b/db/migrate/20191124150431_change_label_id_index_to_include_action_on_label_events.rb
new file mode 100644
index 00000000000..bd138adc5fa
--- /dev/null
+++ b/db/migrate/20191124150431_change_label_id_index_to_include_action_on_label_events.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ChangeLabelIdIndexToIncludeActionOnLabelEvents < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:resource_label_events, %I[label_id action])
+
+ remove_concurrent_index(:resource_label_events, :label_id)
+ end
+
+ def down
+ add_concurrent_index(:resource_label_events, :label_id)
+
+ remove_concurrent_index(:resource_label_events, %I[label_id action])
+ end
+end
diff --git a/db/migrate/20191125114345_add_admin_mode_protected_path.rb b/db/migrate/20191125114345_add_admin_mode_protected_path.rb
new file mode 100644
index 00000000000..7e9b0d5a285
--- /dev/null
+++ b/db/migrate/20191125114345_add_admin_mode_protected_path.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+class AddAdminModeProtectedPath < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ ADMIN_MODE_ENDPOINT = '/admin/session'
+
+ OLD_DEFAULT_PROTECTED_PATHS = [
+ '/users/password',
+ '/users/sign_in',
+ '/api/v3/session.json',
+ '/api/v3/session',
+ '/api/v4/session.json',
+ '/api/v4/session',
+ '/users',
+ '/users/confirmation',
+ '/unsubscribes/',
+ '/import/github/personal_access_token'
+ ]
+
+ NEW_DEFAULT_PROTECTED_PATHS = OLD_DEFAULT_PROTECTED_PATHS.dup << ADMIN_MODE_ENDPOINT
+
+ class ApplicationSetting < ActiveRecord::Base
+ self.table_name = 'application_settings'
+ end
+
+ def up
+ change_column_default :application_settings, :protected_paths, NEW_DEFAULT_PROTECTED_PATHS
+
+ # schema allows nulls for protected_paths
+ ApplicationSetting.where.not(protected_paths: nil).each do |application_setting|
+ unless application_setting.protected_paths.include?(ADMIN_MODE_ENDPOINT)
+ updated_protected_paths = application_setting.protected_paths << ADMIN_MODE_ENDPOINT
+
+ application_setting.update(protected_paths: updated_protected_paths)
+ end
+ end
+ end
+
+ def down
+ change_column_default :application_settings, :protected_paths, OLD_DEFAULT_PROTECTED_PATHS
+
+ # schema allows nulls for protected_paths
+ ApplicationSetting.where.not(protected_paths: nil).each do |application_setting|
+ if application_setting.protected_paths.include?(ADMIN_MODE_ENDPOINT)
+ updated_protected_paths = application_setting.protected_paths - [ADMIN_MODE_ENDPOINT]
+
+ application_setting.update(protected_paths: updated_protected_paths)
+ end
+ end
+ end
+end
diff --git a/db/migrate/20191125133353_add_target_path_to_broadcast_message.rb b/db/migrate/20191125133353_add_target_path_to_broadcast_message.rb
new file mode 100644
index 00000000000..65aa758e502
--- /dev/null
+++ b/db/migrate/20191125133353_add_target_path_to_broadcast_message.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddTargetPathToBroadcastMessage < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :broadcast_messages, :target_path, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191125140458_create_import_failures.rb b/db/migrate/20191125140458_create_import_failures.rb
new file mode 100644
index 00000000000..43e8efe90a4
--- /dev/null
+++ b/db/migrate/20191125140458_create_import_failures.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateImportFailures < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :import_failures do |t|
+ t.integer :relation_index
+ t.references :project, null: false, index: true
+ t.datetime_with_timezone :created_at, null: false
+ t.string :relation_key, limit: 64
+ t.string :exception_class, limit: 128
+ t.string :correlation_id_value, limit: 128, index: true
+ t.string :exception_message, limit: 255
+ end
+ end
+end
diff --git a/db/migrate/20191127030005_create_serverless_domain_cluster.rb b/db/migrate/20191127030005_create_serverless_domain_cluster.rb
new file mode 100644
index 00000000000..7fb24400b0d
--- /dev/null
+++ b/db/migrate/20191127030005_create_serverless_domain_cluster.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateServerlessDomainCluster < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ create_table :serverless_domain_cluster, id: false, primary_key: :uuid do |t|
+ t.references :pages_domain, null: false, foreign_key: { on_delete: :cascade }
+ t.references :clusters_applications_knative, null: false,
+ foreign_key: { to_table: :clusters_applications_knative, on_delete: :cascade },
+ index: { name: :idx_serverless_domain_cluster_on_clusters_applications_knative, unique: true }
+ t.references :creator, name: :created_by, foreign_key: { to_table: :users, on_delete: :nullify }
+ t.timestamps_with_timezone null: false
+ t.string :uuid, null: false, limit: 14, primary_key: true
+ end
+ end
+end
diff --git a/db/migrate/20191127151619_create_gitlab_subscription_histories.rb b/db/migrate/20191127151619_create_gitlab_subscription_histories.rb
new file mode 100644
index 00000000000..718f2c1b313
--- /dev/null
+++ b/db/migrate/20191127151619_create_gitlab_subscription_histories.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class CreateGitlabSubscriptionHistories < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ create_table :gitlab_subscription_histories do |t|
+ t.datetime_with_timezone :gitlab_subscription_created_at
+ t.datetime_with_timezone :gitlab_subscription_updated_at
+ t.date :start_date
+ t.date :end_date
+ t.date :trial_ends_on
+ t.integer :namespace_id, null: true
+ t.integer :hosted_plan_id, null: true
+ t.integer :max_seats_used
+ t.integer :seats
+ t.boolean :trial
+ t.integer :change_type, limit: 2
+ t.bigint :gitlab_subscription_id, null: false
+ t.datetime_with_timezone :created_at
+ end
+ add_index :gitlab_subscription_histories, :gitlab_subscription_id
+ end
+
+ def down
+ drop_table :gitlab_subscription_histories
+ end
+end
diff --git a/db/migrate/20191127151629_add_trial_starts_on_to_gitlab_subscriptions.rb b/db/migrate/20191127151629_add_trial_starts_on_to_gitlab_subscriptions.rb
new file mode 100644
index 00000000000..2528aa9c2c8
--- /dev/null
+++ b/db/migrate/20191127151629_add_trial_starts_on_to_gitlab_subscriptions.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddTrialStartsOnToGitlabSubscriptions < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :gitlab_subscriptions, :trial_starts_on, :date, null: true
+ add_column :gitlab_subscription_histories, :trial_starts_on, :date, null: true
+ end
+end
diff --git a/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb b/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb
new file mode 100644
index 00000000000..6893a02bcad
--- /dev/null
+++ b/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddWildcardAndDomainTypeToPagesDomains < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ PROJECT_TYPE = 2
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default :pages_domains, :wildcard, :boolean, default: false
+ add_column_with_default :pages_domains, :domain_type, :integer, limit: 2, default: PROJECT_TYPE
+ end
+
+ def down
+ remove_column :pages_domains, :wildcard
+ remove_column :pages_domains, :domain_type
+ end
+end
diff --git a/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb b/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb
new file mode 100644
index 00000000000..84d17f558d1
--- /dev/null
+++ b/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddBroadcastTypeToBroadcastMessage < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+ BROADCAST_MESSAGE_BANNER_TYPE = 1
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:broadcast_messages, :broadcast_type, :smallint, default: BROADCAST_MESSAGE_BANNER_TYPE)
+ end
+
+ def down
+ remove_column(:broadcast_messages, :broadcast_type)
+ end
+end
diff --git a/db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb b/db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb
new file mode 100644
index 00000000000..bce191a7ec0
--- /dev/null
+++ b/db/migrate/20191202181924_add_environment_auto_stop_in_to_ci_builds_metadata.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddEnvironmentAutoStopInToCiBuildsMetadata < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column :ci_builds_metadata, :environment_auto_stop_in, :string, limit: 255
+ end
+
+ def down
+ remove_column :ci_builds_metadata, :environment_auto_stop_in
+ end
+end
diff --git a/db/migrate/20191203121729_update_group_deletion_schedules_foreign_keys.rb b/db/migrate/20191203121729_update_group_deletion_schedules_foreign_keys.rb
new file mode 100644
index 00000000000..99531a1e93e
--- /dev/null
+++ b/db/migrate/20191203121729_update_group_deletion_schedules_foreign_keys.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class UpdateGroupDeletionSchedulesForeignKeys < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key(:group_deletion_schedules, :users, column: :user_id, on_delete: :cascade, name: new_foreign_key_name)
+ remove_foreign_key_if_exists(:group_deletion_schedules, column: :user_id, on_delete: :nullify)
+ end
+
+ def down
+ add_concurrent_foreign_key(:group_deletion_schedules, :users, column: :user_id, on_delete: :nullify, name: existing_foreign_key_name)
+ remove_foreign_key_if_exists(:group_deletion_schedules, column: :user_id, on_delete: :cascade)
+ end
+
+ private
+
+ def new_foreign_key_name
+ concurrent_foreign_key_name(:group_deletion_schedules, :user_id)
+ end
+
+ def existing_foreign_key_name
+ 'fk_group_deletion_schedules_users_user_id'
+ end
+end
diff --git a/db/migrate/20191204070713_change_updated_at_index_and_add_index_to_id_on_deployments.rb b/db/migrate/20191204070713_change_updated_at_index_and_add_index_to_id_on_deployments.rb
new file mode 100644
index 00000000000..450b276e689
--- /dev/null
+++ b/db/migrate/20191204070713_change_updated_at_index_and_add_index_to_id_on_deployments.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class ChangeUpdatedAtIndexAndAddIndexToIdOnDeployments < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ PROJECT_ID_INDEX_PARAMS = [[:project_id, :id], order: { id: :desc }]
+ OLD_UPDATED_AT_INDEX_PARAMS = [[:project_id, :updated_at]]
+ NEW_UPDATED_AT_INDEX_PARAMS = [[:project_id, :updated_at, :id], order: { updated_at: :desc, id: :desc }]
+
+ def up
+ add_concurrent_index :deployments, *NEW_UPDATED_AT_INDEX_PARAMS
+
+ remove_concurrent_index :deployments, *OLD_UPDATED_AT_INDEX_PARAMS
+
+ add_concurrent_index :deployments, *PROJECT_ID_INDEX_PARAMS
+ end
+
+ def down
+ add_concurrent_index :deployments, *OLD_UPDATED_AT_INDEX_PARAMS
+
+ remove_concurrent_index :deployments, *NEW_UPDATED_AT_INDEX_PARAMS
+
+ remove_concurrent_index :deployments, *PROJECT_ID_INDEX_PARAMS
+ end
+end
diff --git a/db/migrate/20191204093410_add_label_project_group_partial_indexes.rb b/db/migrate/20191204093410_add_label_project_group_partial_indexes.rb
new file mode 100644
index 00000000000..85666144856
--- /dev/null
+++ b/db/migrate/20191204093410_add_label_project_group_partial_indexes.rb
@@ -0,0 +1,25 @@
+# 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 AddLabelProjectGroupPartialIndexes < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ PROJECT_AND_TITLE = [:project_id, :title]
+ GROUP_AND_TITLE = [:group_id, :title]
+
+ def up
+ add_concurrent_index :labels, PROJECT_AND_TITLE, unique: false, where: "labels.group_id = null"
+ add_concurrent_index :labels, GROUP_AND_TITLE, unique: false, where: "labels.project_id = null"
+ end
+
+ def down
+ remove_concurrent_index :labels, PROJECT_AND_TITLE
+ remove_concurrent_index :labels, GROUP_AND_TITLE
+ end
+end
diff --git a/db/migrate/20191204192726_add_design_disk_path_to_geo_hashed_storage_migrated_events.rb b/db/migrate/20191204192726_add_design_disk_path_to_geo_hashed_storage_migrated_events.rb
new file mode 100644
index 00000000000..39b5d5c7e97
--- /dev/null
+++ b/db/migrate/20191204192726_add_design_disk_path_to_geo_hashed_storage_migrated_events.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddDesignDiskPathToGeoHashedStorageMigratedEvents < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def change
+ add_column :geo_hashed_storage_migrated_events, :old_design_disk_path, :text
+ add_column :geo_hashed_storage_migrated_events, :new_design_disk_path, :text
+ end
+end
diff --git a/db/migrate/20191205060723_add_index_to_keys.rb b/db/migrate/20191205060723_add_index_to_keys.rb
new file mode 100644
index 00000000000..8e8c725f62e
--- /dev/null
+++ b/db/migrate/20191205060723_add_index_to_keys.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToKeys < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :keys, :last_used_at, order: { last_used_at: 'DESC NULLS LAST' }
+ end
+
+ def down
+ remove_concurrent_index :keys, :last_used_at
+ end
+end
diff --git a/db/migrate/20191205094702_add_index_for_cross_projects_dependencies_to_ci_builds.rb b/db/migrate/20191205094702_add_index_for_cross_projects_dependencies_to_ci_builds.rb
new file mode 100644
index 00000000000..023414fb4bb
--- /dev/null
+++ b/db/migrate/20191205094702_add_index_for_cross_projects_dependencies_to_ci_builds.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexForCrossProjectsDependenciesToCiBuilds < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :ci_builds, [:project_id, :name, :ref],
+ where: "type = 'Ci::Build' AND status = 'success' AND (retried = FALSE OR retried IS NULL)"
+ end
+
+ def down
+ remove_concurrent_index :ci_builds, [:project_id, :name, :ref],
+ where: "type = 'Ci::Build' AND status = 'success' AND (retried = FALSE OR retried IS NULL)"
+ end
+end
diff --git a/db/migrate/20191205145647_add_index_to_projects_deploy_keys_deploy_key.rb b/db/migrate/20191205145647_add_index_to_projects_deploy_keys_deploy_key.rb
new file mode 100644
index 00000000000..f9cdc226e4d
--- /dev/null
+++ b/db/migrate/20191205145647_add_index_to_projects_deploy_keys_deploy_key.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddIndexToProjectsDeployKeysDeployKey < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ add_concurrent_index :deploy_keys_projects, :deploy_key_id
+ end
+
+ def down
+ remove_concurrent_index :deploy_keys_projects, :deploy_key_id
+ end
+end
diff --git a/db/migrate/20191206022133_add_indexes_to_pages_domains_on_wildcard_and_domain_type.rb b/db/migrate/20191206022133_add_indexes_to_pages_domains_on_wildcard_and_domain_type.rb
new file mode 100644
index 00000000000..3c1704a3377
--- /dev/null
+++ b/db/migrate/20191206022133_add_indexes_to_pages_domains_on_wildcard_and_domain_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddIndexesToPagesDomainsOnWildcardAndDomainType < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :pages_domains, :wildcard
+ add_concurrent_index :pages_domains, :domain_type
+ end
+
+ def down
+ remove_concurrent_index :pages_domains, :wildcard
+ remove_concurrent_index :pages_domains, :domain_type
+ end
+end
diff --git a/db/migrate/20191206122926_update_index_for_pool_repositories.rb b/db/migrate/20191206122926_update_index_for_pool_repositories.rb
new file mode 100644
index 00000000000..f88e8e94ee1
--- /dev/null
+++ b/db/migrate/20191206122926_update_index_for_pool_repositories.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class UpdateIndexForPoolRepositories < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # This index is less restrictive then the one we already have, no need to
+ # update data.
+ add_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true
+ remove_concurrent_index :pool_repositories, :source_project_id
+ end
+
+ def down
+ # Not adding this index as a unique one, since while the new index existed
+ # we could have created multiple pool repositories for a project. In that
+ # case this rollback would fail.
+ add_concurrent_index :pool_repositories, :source_project_id
+ remove_concurrent_index :pool_repositories, [:source_project_id, :shard_id], unique: true
+ end
+end
diff --git a/db/migrate/20191208071111_add_fingerprint_sha256_to_key.rb b/db/migrate/20191208071111_add_fingerprint_sha256_to_key.rb
new file mode 100644
index 00000000000..1bc87357f7d
--- /dev/null
+++ b/db/migrate/20191208071111_add_fingerprint_sha256_to_key.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddFingerprintSha256ToKey < ActiveRecord::Migration[5.0]
+ DOWNTIME = false
+
+ def up
+ add_column(:keys, :fingerprint_sha256, :binary)
+ end
+
+ def down
+ remove_column(:keys, :fingerprint_sha256) if column_exists?(:keys, :fingerprint_sha256)
+ end
+end
diff --git a/db/migrate/20191208071112_add_fingerprint_sha256_index_to_key.rb b/db/migrate/20191208071112_add_fingerprint_sha256_index_to_key.rb
new file mode 100644
index 00000000000..6f0c4bcd321
--- /dev/null
+++ b/db/migrate/20191208071112_add_fingerprint_sha256_index_to_key.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddFingerprintSha256IndexToKey < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:keys, "fingerprint_sha256")
+ end
+
+ def down
+ remove_concurrent_index(:keys, "fingerprint_sha256")
+ end
+end
diff --git a/db/migrate/20191212140117_change_commit_user_mentions_commit_id_column_type.rb b/db/migrate/20191212140117_change_commit_user_mentions_commit_id_column_type.rb
new file mode 100644
index 00000000000..f30cdab3441
--- /dev/null
+++ b/db/migrate/20191212140117_change_commit_user_mentions_commit_id_column_type.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class ChangeCommitUserMentionsCommitIdColumnType < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ OLD_INDEX = 'commit_user_mentions_on_commit_id_and_note_id_index'
+ OLD_TMP_INDEX = 'temp_commit_id_and_note_id_index'
+ NEW_TMP_INDEX = 'temp_commit_id_for_type_change_and_note_id_index'
+ NEW_INDEX = 'commit_id_and_note_id_index'
+
+ def up
+ # the initial index name is too long and fails during migration. Renaming the index first.
+ add_concurrent_index :commit_user_mentions, [:commit_id, :note_id], name: OLD_TMP_INDEX
+ remove_concurrent_index_by_name :commit_user_mentions, OLD_INDEX
+
+ change_column_type_concurrently :commit_user_mentions, :commit_id, :string
+
+ # change_column_type_concurrently creates a new index for new column `commit_id_for_type` based on existing
+ # `temp_commit_id_and_note_id_index` naming it `temp_commit_id_for_type_change_and_note_id_index`, yet keeping
+ # `temp_commit_id_and_note_id_index` for `commit_id`, that will be cleaned
+ # by `cleanup_concurrent_column_type_change :commit_user_mentions, :commit_id` in a later migration.
+ #
+ # So we'll rename `temp_commit_id_for_type_change_and_note_id_index` to initialy intended name: `commit_id_and_note_id_index`.
+
+ add_concurrent_index :commit_user_mentions, [:commit_id_for_type_change, :note_id], name: NEW_INDEX
+ remove_concurrent_index_by_name :commit_user_mentions, NEW_TMP_INDEX
+ end
+
+ def down
+ cleanup_concurrent_column_type_change :commit_user_mentions, :commit_id
+ end
+end
diff --git a/db/migrate/20191213104838_add_service_desk_username.rb b/db/migrate/20191213104838_add_service_desk_username.rb
new file mode 100644
index 00000000000..945bdb67fa1
--- /dev/null
+++ b/db/migrate/20191213104838_add_service_desk_username.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddServiceDeskUsername < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column :service_desk_settings, :outgoing_name, :string, limit: 255
+ end
+end
diff --git a/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb b/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb
new file mode 100644
index 00000000000..5dacc3c0c66
--- /dev/null
+++ b/db/migrate/20191214175727_add_indexes_to_deployments_on_project_id_and_ref.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddIndexesToDeploymentsOnProjectIdAndRef < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'partial_index_deployments_for_project_id_and_tag'.freeze
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :deployments, [:project_id, :ref]
+ add_concurrent_index :deployments, [:project_id], where: 'tag IS TRUE', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :deployments, [:project_id, :ref]
+ remove_concurrent_index :deployments, [:project_id], where: 'tag IS TRUE', name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20191216094119_add_id_to_plan_limits.rb b/db/migrate/20191216094119_add_id_to_plan_limits.rb
new file mode 100644
index 00000000000..05ebd900df3
--- /dev/null
+++ b/db/migrate/20191216094119_add_id_to_plan_limits.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AddIdToPlanLimits < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ add_column(:plan_limits, :id, :primary_key) unless column_exists?(:plan_limits, :id)
+ end
+
+ def down
+ remove_column(:plan_limits, :id)
+ end
+end
diff --git a/db/migrate/20191216183531_add_project_hooks_to_plan_limits.rb b/db/migrate/20191216183531_add_project_hooks_to_plan_limits.rb
new file mode 100644
index 00000000000..c56b6edf029
--- /dev/null
+++ b/db/migrate/20191216183531_add_project_hooks_to_plan_limits.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectHooksToPlanLimits < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def change
+ add_column(:plan_limits, :project_hooks, :integer, default: 0, null: false)
+ end
+end
diff --git a/db/migrate/20191216183532_insert_project_hooks_plan_limits.rb b/db/migrate/20191216183532_insert_project_hooks_plan_limits.rb
new file mode 100644
index 00000000000..b2c0121dd24
--- /dev/null
+++ b/db/migrate/20191216183532_insert_project_hooks_plan_limits.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class InsertProjectHooksPlanLimits < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ return unless Gitlab.com?
+
+ create_or_update_plan_limit('project_hooks', 'free', 10)
+ create_or_update_plan_limit('project_hooks', 'bronze', 20)
+ create_or_update_plan_limit('project_hooks', 'silver', 30)
+ create_or_update_plan_limit('project_hooks', 'gold', 100)
+ end
+
+ def down
+ return unless Gitlab.com?
+
+ create_or_update_plan_limit('project_hooks', 'free', 0)
+ create_or_update_plan_limit('project_hooks', 'bronze', 0)
+ create_or_update_plan_limit('project_hooks', 'silver', 0)
+ create_or_update_plan_limit('project_hooks', 'gold', 0)
+ end
+end
diff --git a/db/optional_migrations/composite_primary_keys.rb b/db/optional_migrations/composite_primary_keys.rb
index e0bb0312a35..1fcb9664ff6 100644
--- a/db/optional_migrations/composite_primary_keys.rb
+++ b/db/optional_migrations/composite_primary_keys.rb
@@ -27,8 +27,6 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- return unless Gitlab::Database.postgresql?
-
disable_statement_timeout do
TABLES.each do |index|
add_primary_key(index)
@@ -37,8 +35,6 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration[4.2]
end
def down
- return unless Gitlab::Database.postgresql?
-
disable_statement_timeout do
TABLES.each do |index|
remove_primary_key(index)
diff --git a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
index 88b713aaef3..66ad0a89539 100644
--- a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
+++ b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
@@ -50,17 +50,9 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration[4.2]
UPDATE ci_builds SET stage_id = NULL WHERE stage_id IN (#{redundant_stages_ids})
SQL
- if Gitlab::Database.postgresql?
- execute <<~SQL
- DELETE FROM ci_stages WHERE id IN (#{redundant_stages_ids})
- SQL
- else # We can't modify a table we are selecting from on MySQL
- execute <<~SQL
- DELETE a FROM ci_stages AS a, ci_stages AS b
- WHERE a.pipeline_id = b.pipeline_id AND a.name = b.name
- AND a.id <> b.id
- SQL
- end
+ execute <<~SQL
+ DELETE FROM ci_stages WHERE id IN (#{redundant_stages_ids})
+ SQL
end
end
end
diff --git a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb
index 325895a5ddb..1eb49d60da5 100644
--- a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb
+++ b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb
@@ -12,11 +12,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- if Gitlab::Database.postgresql?
- PostgresStrategy.new
- else
- MysqlStrategy.new
- end.up
+ PostgresStrategy.new.up
if index_exists_by_name?(:user_interacted_projects, CreateUserInteractedProjectsTable::INDEX_NAME)
remove_concurrent_index_by_name :user_interacted_projects, CreateUserInteractedProjectsTable::INDEX_NAME
@@ -140,30 +136,4 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
remove_concurrent_index(*args) if index_exists?(*args)
end
end
-
- class MysqlStrategy < ActiveRecord::Migration[4.2]
- include Gitlab::Database::MigrationHelpers
-
- def up
- execute <<~SQL
- INSERT INTO user_interacted_projects (user_id, project_id)
- SELECT e.user_id, e.project_id
- FROM (SELECT DISTINCT author_id AS user_id, project_id FROM events WHERE project_id IS NOT NULL) AS e
- LEFT JOIN user_interacted_projects ucp USING (user_id, project_id)
- WHERE ucp.user_id IS NULL
- SQL
-
- unless index_exists?(:user_interacted_projects, [:project_id, :user_id])
- add_concurrent_index :user_interacted_projects, [:project_id, :user_id], unique: true, name: UNIQUE_INDEX_NAME
- end
-
- unless foreign_key_exists?(:user_interacted_projects, :users, column: :user_id)
- add_concurrent_foreign_key :user_interacted_projects, :users, column: :user_id, on_delete: :cascade
- end
-
- unless foreign_key_exists?(:user_interacted_projects, :projects, column: :project_id)
- add_concurrent_foreign_key :user_interacted_projects, :projects, column: :project_id, on_delete: :cascade
- end
- end
- end
end
diff --git a/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb b/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
index 3b3cb4267d4..e363642b2ac 100644
--- a/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
+++ b/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
@@ -14,11 +14,9 @@ class RemovePermanentFromRedirectRoutes < ActiveRecord::Migration[4.2]
# These indexes were created on Postgres only in:
# ReworkRedirectRoutesIndexes:
# https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/16211
- if Gitlab::Database.postgresql?
- disable_statement_timeout do
- execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME_PERM};"
- execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME_TEMP};"
- end
+ disable_statement_timeout do
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME_PERM};"
+ execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME_TEMP};"
end
remove_column(:redirect_routes, :permanent)
@@ -27,11 +25,9 @@ class RemovePermanentFromRedirectRoutes < ActiveRecord::Migration[4.2]
def down
add_column(:redirect_routes, :permanent, :boolean)
- if Gitlab::Database.postgresql?
- disable_statement_timeout do
- execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME_PERM} ON redirect_routes (lower(path) varchar_pattern_ops) where (permanent);")
- execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME_TEMP} ON redirect_routes (lower(path) varchar_pattern_ops) where (not permanent or permanent is null) ;")
- end
+ disable_statement_timeout do
+ execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME_PERM} ON redirect_routes (lower(path) varchar_pattern_ops) where (permanent);")
+ execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME_TEMP} ON redirect_routes (lower(path) varchar_pattern_ops) where (not permanent or permanent is null) ;")
end
end
end
diff --git a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
index d44ec1036c4..f0257e303f7 100644
--- a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
+++ b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
@@ -16,8 +16,6 @@ class AddPathIndexToRedirectRoutes < ActiveRecord::Migration[4.2]
# This same index is also added in the `ReworkRedirectRoutesIndexes` so this
# is a no-op in most cases.
def up
- return unless Gitlab::Database.postgresql?
-
disable_statement_timeout do
unless index_exists_by_name?(:redirect_routes, INDEX_NAME)
execute("CREATE UNIQUE INDEX CONCURRENTLY #{INDEX_NAME} ON redirect_routes (lower(path) varchar_pattern_ops);")
diff --git a/db/post_migrate/20180706223200_populate_site_statistics.rb b/db/post_migrate/20180706223200_populate_site_statistics.rb
index 0859aa88866..6f887a0c18f 100644
--- a/db/post_migrate/20180706223200_populate_site_statistics.rb
+++ b/db/post_migrate/20180706223200_populate_site_statistics.rb
@@ -7,13 +7,13 @@ class PopulateSiteStatistics < ActiveRecord::Migration[4.2]
def up
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
execute("UPDATE site_statistics SET repositories_count = (SELECT COUNT(*) FROM projects)")
end
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)")
end
diff --git a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
index 9bf6aed833d..b272bad7f92 100644
--- a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
+++ b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
@@ -20,7 +20,7 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration[4.2]
# We need to re-count wikis as previous attempt was not considering the NULLs.
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)")
end
diff --git a/db/post_migrate/20180826111825_recalculate_site_statistics.rb b/db/post_migrate/20180826111825_recalculate_site_statistics.rb
index 7c1fca3884d..938707c9ba4 100644
--- a/db/post_migrate/20180826111825_recalculate_site_statistics.rb
+++ b/db/post_migrate/20180826111825_recalculate_site_statistics.rb
@@ -9,13 +9,13 @@ class RecalculateSiteStatistics < ActiveRecord::Migration[4.2]
def up
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
execute("UPDATE site_statistics SET repositories_count = (SELECT COUNT(*) FROM projects)")
end
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') # see https://gitlab.com/gitlab-org/gitlab-foss/issues/48967
execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)")
end
diff --git a/db/post_migrate/20191015154408_drop_merge_requests_require_code_owner_approval_from_projects.rb b/db/post_migrate/20191015154408_drop_merge_requests_require_code_owner_approval_from_projects.rb
new file mode 100644
index 00000000000..a1d763b7ed1
--- /dev/null
+++ b/db/post_migrate/20191015154408_drop_merge_requests_require_code_owner_approval_from_projects.rb
@@ -0,0 +1,27 @@
+# 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 DropMergeRequestsRequireCodeOwnerApprovalFromProjects < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ remove_column :projects, :merge_requests_require_code_owner_approval, :boolean
+ end
+
+ def down
+ add_column :projects, :merge_requests_require_code_owner_approval, :boolean
+
+ add_concurrent_index(
+ :projects,
+ %i[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))'
+ )
+ end
+end
diff --git a/db/post_migrate/20191030223057_backfill_version_author_and_created_at.rb b/db/post_migrate/20191030223057_backfill_version_author_and_created_at.rb
new file mode 100644
index 00000000000..7a6d0b089a0
--- /dev/null
+++ b/db/post_migrate/20191030223057_backfill_version_author_and_created_at.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+class BackfillVersionAuthorAndCreatedAt < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+ MIGRATION = 'BackfillVersionDataFromGitaly'.freeze
+ BATCH_SIZE = 500
+
+ disable_ddl_transaction!
+
+ class Project < ActiveRecord::Base
+ self.table_name = 'projects'
+ self.inheritance_column = :_type_disabled
+ end
+
+ class Issue < ActiveRecord::Base
+ self.table_name = 'issues'
+ self.inheritance_column = :_type_disabled
+ end
+
+ class Version < ActiveRecord::Base
+ include EachBatch
+ self.table_name = 'design_management_versions'
+ self.inheritance_column = :_type_disabled
+
+ # Returns unique issue ids of versions that are not in projects
+ # that are pending deletion.
+ scope :with_unique_issue_ids, -> do
+ versions = Version.arel_table
+ issues = Issue.arel_table
+ projects = Project.arel_table
+
+ Version.select(versions[:issue_id]).where(
+ versions[:author_id].eq(nil).or(
+ versions[:created_at].eq(nil)
+ ).and(
+ issues[:project_id].not_in(
+ projects.project(projects[:id]).where(projects[:pending_delete].eq(true))
+ )
+ )
+ ).joins(
+ versions.join(issues).on(
+ issues[:id].eq(versions[:issue_id])
+ ).join_sources
+ ).distinct
+ end
+ end
+
+ # This migration will make around ~1300 UPDATE queries on GitLab.com,
+ # one per design_management_versions record as the migration will update
+ # each record individually.
+ #
+ # It will make around 870 Gitaly `ListCommitsByOid` requests on GitLab.com.
+ # One for every unique issue with design_management_versions records.
+ def up
+ return unless Gitlab.ee? # no-op for CE
+
+ Version.with_unique_issue_ids.each_batch(of: BATCH_SIZE) do |versions, index|
+ jobs = versions.map { |version| [MIGRATION, [version.issue_id]] }
+
+ BackgroundMigrationWorker.bulk_perform_async(jobs)
+ end
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20191104142124_nullify_users_role.rb b/db/post_migrate/20191104142124_nullify_users_role.rb
new file mode 100644
index 00000000000..540d58e95ba
--- /dev/null
+++ b/db/post_migrate/20191104142124_nullify_users_role.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class NullifyUsersRole < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+ INDEX_NAME = 'partial_index_users_updated_at_for_cleaning_mistaken_values'.freeze
+
+ DOWNTIME = false
+
+ def up
+ # expected updated users count is around 10K
+ # rubocop: disable Migration/UpdateLargeTable
+ add_concurrent_index(:users, :updated_at, where: 'role = 0', name: INDEX_NAME)
+
+ update_column_in_batches(:users, :role, nil) do |table, query|
+ query.where(table[:updated_at].lt('2019-11-05 12:08:00')).where(table[:role].eq(0))
+ end
+
+ remove_concurrent_index_by_name(:users, INDEX_NAME)
+ end
+
+ def down
+ # noop
+ 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
index 6b7a158584d..5a8529c24d7 100644
--- a/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
+++ b/db/post_migrate/20191105094625_set_report_type_for_vulnerabilities.rb
@@ -4,12 +4,20 @@ class SetReportTypeForVulnerabilities < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
- # set report_type based on associated vulnerability_occurrences
+ # set report_type based on vulnerability_occurrences from which the vulnerabilities were promoted,
+ # that is, first vulnerability_occurrences among those having the same vulnerability_id
execute <<~SQL
+ WITH first_findings_for_vulnerabilities AS (
+ SELECT MIN(id) AS id, vulnerability_id
+ FROM vulnerability_occurrences
+ WHERE vulnerability_id IS NOT NULL
+ GROUP BY vulnerability_id
+ )
UPDATE vulnerabilities
SET report_type = vulnerability_occurrences.report_type
- FROM vulnerability_occurrences
- WHERE vulnerabilities.id = vulnerability_occurrences.vulnerability_id
+ FROM vulnerability_occurrences, first_findings_for_vulnerabilities
+ WHERE vulnerability_occurrences.id = first_findings_for_vulnerabilities.id
+ AND vulnerabilities.id = vulnerability_occurrences.vulnerability_id
SQL
# set default report_type for orphan vulnerabilities (there should be none but...)
diff --git a/db/post_migrate/20191108202723_add_unique_constraint_to_software_licenses.rb b/db/post_migrate/20191108202723_add_unique_constraint_to_software_licenses.rb
new file mode 100644
index 00000000000..580d3a189c8
--- /dev/null
+++ b/db/post_migrate/20191108202723_add_unique_constraint_to_software_licenses.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+class AddUniqueConstraintToSoftwareLicenses < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+ NEW_INDEX = 'index_software_licenses_on_unique_name'
+ OLD_INDEX = 'index_software_licenses_on_name'
+
+ disable_ddl_transaction!
+
+ # 12 software licenses will be removed on GitLab.com
+ # 0 software license policies will be updated on GitLab.com
+ def up(attempts: 100)
+ remove_redundant_software_licenses!
+
+ add_concurrent_index :software_licenses, :name, unique: true, name: NEW_INDEX
+ remove_concurrent_index :software_licenses, :name, name: OLD_INDEX
+ rescue ActiveRecord::RecordNotUnique
+ retry if (attempts -= 1) > 0
+
+ raise StandardError, <<~EOS
+ Failed to add an unique index to software_licenses, despite retrying the
+ migration 100 times.
+
+ See https://gitlab.com/gitlab-org/gitlab/merge_requests/19840.
+ EOS
+ end
+
+ def down
+ remove_concurrent_index :software_licenses, :name, unique: true, name: NEW_INDEX
+ add_concurrent_index :software_licenses, :name, name: OLD_INDEX
+ end
+
+ private
+
+ def remove_redundant_software_licenses!
+ redundant_software_licenses = execute <<~SQL
+ SELECT min(id) id, name
+ FROM software_licenses
+ WHERE name IN (select name from software_licenses group by name having count(name) > 1)
+ GROUP BY name
+ SQL
+ say "Detected #{redundant_software_licenses.count} duplicates."
+
+ redundant_software_licenses.each_row do |id, name|
+ say_with_time("Reassigning policies that reference software license #{name}.") do
+ duplicates = software_licenses.where.not(id: id).where(name: name)
+
+ software_license_policies
+ .where(software_license_id: duplicates)
+ .update_all(software_license_id: id)
+
+ duplicates.delete_all
+ end
+ end
+ end
+
+ def table(name)
+ Class.new(ActiveRecord::Base) { self.table_name = name }
+ end
+
+ def software_licenses
+ @software_licenses ||= table(:software_licenses)
+ end
+
+ def software_license_policies
+ @software_license_policies ||= table(:software_license_policies)
+ end
+end
diff --git a/db/post_migrate/20191112023159_complete_pages_metadata_migration.rb b/db/post_migrate/20191112023159_complete_pages_metadata_migration.rb
new file mode 100644
index 00000000000..6468eef8cc1
--- /dev/null
+++ b/db/post_migrate/20191112023159_complete_pages_metadata_migration.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class CompletePagesMetadataMigration < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ Gitlab::BackgroundMigration.steal('MigratePagesMetadata')
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb b/db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb
new file mode 100644
index 00000000000..47622a216d9
--- /dev/null
+++ b/db/post_migrate/20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+class MigrateOpsFeatureFlagsScopesTargetUserIds < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ class OperationsFeatureFlagScope < ActiveRecord::Base
+ include EachBatch
+ self.table_name = 'operations_feature_flag_scopes'
+ self.inheritance_column = :_type_disabled
+ end
+
+ ###
+ # 2019-11-26
+ #
+ # There are about 1000 rows in the operations_feature_flag_scopes table on gitlab.com.
+ # This migration will update about 30 of them.
+ # https://gitlab.com/gitlab-org/gitlab/merge_requests/20325#note_250742098
+ #
+ # This should take a few seconds to run.
+ # https://gitlab.com/gitlab-org/gitlab/merge_requests/20325#note_254871603
+ #
+ ###
+ def up
+ OperationsFeatureFlagScope.where("strategies @> ?", [{ 'name': 'userWithId' }].to_json).each_batch do |scopes|
+ scopes.each do |scope|
+ if scope.active
+ default_strategy = scope.strategies.find { |s| s['name'] == 'default' }
+
+ if default_strategy.present?
+ scope.update({ strategies: [default_strategy] })
+ end
+ else
+ user_with_id_strategy = scope.strategies.find { |s| s['name'] == 'userWithId' }
+
+ scope.update({
+ active: true,
+ strategies: [user_with_id_strategy]
+ })
+ end
+ end
+ end
+ end
+
+ def down
+ # This is not reversible.
+ # The old Target Users feature required the same list of user ids to be applied to each environment scope.
+ # Now we allow the list of user ids to differ for each scope.
+ end
+end
diff --git a/db/post_migrate/20191119221041_cleanup_software_license_policies_classification_rename.rb b/db/post_migrate/20191119221041_cleanup_software_license_policies_classification_rename.rb
new file mode 100644
index 00000000000..eb605dce5aa
--- /dev/null
+++ b/db/post_migrate/20191119221041_cleanup_software_license_policies_classification_rename.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CleanupSoftwareLicensePoliciesClassificationRename < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ cleanup_concurrent_column_rename :software_license_policies, :approval_status, :classification
+ end
+
+ def down
+ undo_cleanup_concurrent_column_rename :software_license_policies, :approval_status, :classification
+ end
+end
diff --git a/db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb b/db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb
new file mode 100644
index 00000000000..9e24f64660c
--- /dev/null
+++ b/db/post_migrate/20191121122856_drop_packages_package_metadata_table.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class DropPackagesPackageMetadataTable < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ drop_table :packages_package_metadata
+ end
+
+ def down
+ create_table :packages_package_metadata do |t|
+ t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer
+ t.binary :metadata, null: false
+ end
+ end
+end
diff --git a/db/post_migrate/20191125024005_cleanup_deploy_access_levels_for_removed_groups.rb b/db/post_migrate/20191125024005_cleanup_deploy_access_levels_for_removed_groups.rb
new file mode 100644
index 00000000000..29592612a02
--- /dev/null
+++ b/db/post_migrate/20191125024005_cleanup_deploy_access_levels_for_removed_groups.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class CleanupDeployAccessLevelsForRemovedGroups < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ return unless Gitlab.ee?
+
+ delete = <<~SQL
+ DELETE FROM protected_environment_deploy_access_levels d
+ USING protected_environments p
+ WHERE d.protected_environment_id=p.id
+ AND d.group_id IS NOT NULL
+ AND NOT EXISTS (SELECT 1 FROM project_group_links WHERE project_id=p.project_id AND group_id=d.group_id)
+ RETURNING *
+ SQL
+
+ # At the time of writing there are 4 such records on GitLab.com,
+ # execution time is expected to be around 15ms.
+ records = execute(delete)
+
+ logger = Gitlab::BackgroundMigration::Logger.build
+ records.to_a.each do |record|
+ logger.info record.as_json.merge(message: "protected_environments_deploy_access_levels was deleted")
+ end
+ end
+
+ def down
+ # There is no pragmatic way to restore
+ # the records deleted in the `#up` method above.
+ end
+end
diff --git a/db/post_migrate/20191202031812_drop_operations_feature_flags_clients_token.rb b/db/post_migrate/20191202031812_drop_operations_feature_flags_clients_token.rb
new file mode 100644
index 00000000000..bda461af7bc
--- /dev/null
+++ b/db/post_migrate/20191202031812_drop_operations_feature_flags_clients_token.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class DropOperationsFeatureFlagsClientsToken < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # Ignored in 12.5 - https://gitlab.com/gitlab-org/gitlab/merge_requests/18923
+ remove_column :operations_feature_flags_clients, :token
+ end
+
+ def down
+ unless column_exists?(:operations_feature_flags_clients, :token)
+ add_column :operations_feature_flags_clients, :token, :string # rubocop:disable Migration/AddLimitToStringColumns
+ end
+
+ add_concurrent_index :operations_feature_flags_clients, [:project_id, :token], unique: true,
+ name: 'index_operations_feature_flags_clients_on_project_id_and_token'
+ end
+end
diff --git a/db/post_migrate/20191205084057_update_minimum_password_length.rb b/db/post_migrate/20191205084057_update_minimum_password_length.rb
new file mode 100644
index 00000000000..d9324347075
--- /dev/null
+++ b/db/post_migrate/20191205084057_update_minimum_password_length.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class UpdateMinimumPasswordLength < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ value_to_be_updated_to = [
+ Devise.password_length.min,
+ ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH
+ ].max
+
+ execute "UPDATE application_settings SET minimum_password_length = #{value_to_be_updated_to}"
+
+ ApplicationSetting.expire
+ end
+
+ def down
+ value_to_be_updated_to = ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH
+
+ execute "UPDATE application_settings SET minimum_password_length = #{value_to_be_updated_to}"
+
+ ApplicationSetting.expire
+ end
+end
diff --git a/db/post_migrate/20191209215316_knative_0_9_prometheus_update.rb b/db/post_migrate/20191209215316_knative_0_9_prometheus_update.rb
new file mode 100644
index 00000000000..52127f71cd0
--- /dev/null
+++ b/db/post_migrate/20191209215316_knative_0_9_prometheus_update.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class Knative09PrometheusUpdate < ActiveRecord::Migration[5.2]
+ DOWNTIME = false
+
+ def up
+ ::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/post_migrate/20191212162434_change_commit_user_mentions_commit_id_column_type_cleanup.rb b/db/post_migrate/20191212162434_change_commit_user_mentions_commit_id_column_type_cleanup.rb
new file mode 100644
index 00000000000..aed9d335af9
--- /dev/null
+++ b/db/post_migrate/20191212162434_change_commit_user_mentions_commit_id_column_type_cleanup.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class ChangeCommitUserMentionsCommitIdColumnTypeCleanup < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ NEW_INDEX = 'commit_id_for_type_change_and_note_id_index'
+ OLD_INDEX = 'commit_user_mentions_on_commit_id_and_note_id_index'
+
+ def up
+ cleanup_concurrent_column_type_change :commit_user_mentions, :commit_id
+ end
+
+ def down
+ change_column_type_concurrently :commit_user_mentions, :commit_id, :binary
+
+ # change_column_type_concurrently creates a new index based on existing commit_id_and_note_id_index` naming it
+ # `commit_id_for_type_change_and_note_id_index` so we'll rename it back to its original name.
+ add_concurrent_index :commit_user_mentions, [:commit_id_for_type_change, :note_id], name: OLD_INDEX
+ remove_concurrent_index_by_name :commit_user_mentions, NEW_INDEX
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0dce19a29d7..acf51164e0b 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_11_22_135327) do
+ActiveRecord::Schema.define(version: 2019_12_16_183532) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -325,10 +325,11 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.string "encrypted_asset_proxy_secret_key_iv"
t.string "static_objects_external_storage_url", limit: 255
t.string "static_objects_external_storage_auth_token", limit: 255
+ t.integer "max_personal_access_token_lifetime"
t.boolean "throttle_protected_paths_enabled", default: false, null: false
t.integer "throttle_protected_paths_requests_per_period", default: 10, null: false
t.integer "throttle_protected_paths_period_in_seconds", default: 60, null: false
- t.string "protected_paths", limit: 255, default: ["/users/password", "/users/sign_in", "/api/v3/session.json", "/api/v3/session", "/api/v4/session.json", "/api/v4/session", "/users", "/users/confirmation", "/unsubscribes/", "/import/github/personal_access_token"], array: true
+ t.string "protected_paths", limit: 255, default: ["/users/password", "/users/sign_in", "/api/v3/session.json", "/api/v3/session", "/api/v4/session.json", "/api/v4/session", "/users", "/users/confirmation", "/unsubscribes/", "/import/github/personal_access_token", "/admin/session"], array: true
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
@@ -349,6 +350,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.boolean "sourcegraph_enabled", default: false, null: false
t.string "sourcegraph_url", limit: 255
t.boolean "sourcegraph_public_only", default: true, null: false
+ t.bigint "snippet_size_limit", default: 52428800, null: false
+ t.integer "minimum_password_length", default: 8, null: false
t.text "encrypted_akismet_api_key"
t.string "encrypted_akismet_api_key_iv", limit: 255
t.text "encrypted_elasticsearch_aws_secret_access_key"
@@ -504,6 +507,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "project_id"
t.integer "group_id"
t.string "type", null: false
+ t.string "name", limit: 255
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
t.index ["group_id"], name: "index_badges_on_group_id"
@@ -571,6 +575,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.string "font"
t.text "message_html", null: false
t.integer "cached_markdown_version"
+ t.string "target_path", limit: 255
+ t.integer "broadcast_type", limit: 2, default: 1, null: false
t.index ["starts_at", "ends_at", "id"], name: "index_broadcast_messages_on_starts_at_and_ends_at_and_id"
end
@@ -600,6 +606,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
create_table "ci_build_needs", id: :serial, force: :cascade do |t|
t.integer "build_id", null: false
t.text "name", null: false
+ t.boolean "artifacts", default: true, null: false
t.index ["build_id", "name"], name: "index_ci_build_needs_on_build_id_and_name", unique: true
end
@@ -686,6 +693,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref"
t.index ["name"], name: "index_ci_builds_on_name_for_security_products_values", where: "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text]))"
t.index ["project_id", "id"], name: "index_ci_builds_on_project_id_and_id"
+ t.index ["project_id", "name", "ref"], name: "index_ci_builds_on_project_id_and_name_and_ref", where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = 'success'::text) AND ((retried = false) OR (retried IS NULL)))"
t.index ["project_id", "status"], name: "index_ci_builds_project_id_and_status_for_live_jobs_partial2", where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))"
t.index ["project_id"], name: "index_ci_builds_on_project_id_for_successfull_pages_deploy", where: "(((type)::text = 'GenericCommitStatus'::text) AND ((stage)::text = 'deploy'::text) AND ((name)::text = 'pages:deploy'::text) AND ((status)::text = 'success'::text))"
t.index ["protected"], name: "index_ci_builds_on_protected"
@@ -712,6 +720,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.jsonb "config_options"
t.jsonb "config_variables"
t.boolean "has_exposed_artifacts"
+ t.string "environment_auto_stop_in", limit: 255
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)"
@@ -817,6 +826,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "pipeline_id", null: false
t.integer "variable_type", limit: 2, default: 1, null: false
t.index ["pipeline_id", "key"], name: "index_ci_pipeline_variables_on_pipeline_id_and_key", unique: true
+ t.index ["pipeline_id"], name: "index_ci_pipeline_variables_on_pipeline_id", where: "((key)::text = 'AUTO_DEVOPS_MODSECURITY_SEC_RULE_ENGINE'::text)"
end
create_table "ci_pipelines", id: :serial, force: :cascade do |t|
@@ -856,6 +866,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha"
t.index ["project_id", "source"], name: "index_ci_pipelines_on_project_id_and_source"
t.index ["project_id", "status", "config_source"], name: "index_ci_pipelines_on_project_id_and_status_and_config_source"
+ t.index ["project_id", "status", "updated_at"], name: "index_ci_pipelines_on_project_id_and_status_and_updated_at"
t.index ["project_id"], name: "index_ci_pipelines_on_project_id"
t.index ["status"], name: "index_ci_pipelines_on_status"
t.index ["user_id"], name: "index_ci_pipelines_on_user_id"
@@ -974,6 +985,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.boolean "masked", default: false, null: false
t.integer "variable_type", limit: 2, default: 1, null: false
t.index ["project_id", "key", "environment_scope"], name: "index_ci_variables_on_project_id_and_key_and_environment_scope", unique: true
+ t.index ["project_id"], name: "index_ci_variables_on_project_id", where: "((key)::text = 'AUTO_DEVOPS_MODSECURITY_SEC_RULE_ENGINE'::text)"
end
create_table "cluster_groups", id: :serial, force: :cascade do |t|
@@ -1204,6 +1216,28 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["project_id"], name: "index_clusters_kubernetes_namespaces_on_project_id"
end
+ create_table "commit_user_mentions", force: :cascade do |t|
+ t.integer "note_id", null: false
+ t.integer "mentioned_users_ids", array: true
+ t.integer "mentioned_projects_ids", array: true
+ t.integer "mentioned_groups_ids", array: true
+ t.string "commit_id", null: false
+ t.index ["commit_id", "note_id"], name: "commit_id_and_note_id_index"
+ t.index ["note_id"], name: "index_commit_user_mentions_on_note_id", unique: true
+ end
+
+ create_table "container_expiration_policies", primary_key: "project_id", id: :bigint, default: nil, force: :cascade do |t|
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.datetime_with_timezone "next_run_at"
+ t.string "name_regex", limit: 255
+ t.string "cadence", limit: 12, default: "7d", null: false
+ t.string "older_than", limit: 12
+ t.integer "keep_n"
+ t.boolean "enabled", default: false, null: false
+ t.index ["next_run_at", "enabled"], name: "index_container_expiration_policies_on_next_run_at_and_enabled"
+ end
+
create_table "container_repositories", id: :serial, force: :cascade do |t|
t.integer "project_id", null: false
t.string "name", null: false
@@ -1273,6 +1307,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "can_push", default: false, null: false
+ t.index ["deploy_key_id"], name: "index_deploy_keys_projects_on_deploy_key_id"
t.index ["project_id"], name: "index_deploy_keys_projects_on_project_id"
end
@@ -1321,10 +1356,13 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["environment_id", "iid", "project_id"], name: "index_deployments_on_environment_id_and_iid_and_project_id"
t.index ["environment_id", "status"], name: "index_deployments_on_environment_id_and_status"
t.index ["id"], name: "partial_index_deployments_for_legacy_successful_deployments", where: "((finished_at IS NULL) AND (status = 2))"
+ t.index ["project_id", "id"], name: "index_deployments_on_project_id_and_id", order: { id: :desc }
t.index ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true
+ t.index ["project_id", "ref"], name: "index_deployments_on_project_id_and_ref"
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"
+ t.index ["project_id", "updated_at", "id"], name: "index_deployments_on_project_id_and_updated_at_and_id", order: { updated_at: :desc, id: :desc }
+ t.index ["project_id"], name: "partial_index_deployments_for_project_id_and_tag", where: "(tag IS TRUE)"
end
create_table "description_versions", force: :cascade do |t|
@@ -1367,6 +1405,16 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["sha", "issue_id"], name: "index_design_management_versions_on_sha_and_issue_id", unique: true
end
+ create_table "design_user_mentions", force: :cascade do |t|
+ t.integer "design_id", null: false
+ t.integer "note_id", null: false
+ t.integer "mentioned_users_ids", array: true
+ t.integer "mentioned_projects_ids", array: true
+ t.integer "mentioned_groups_ids", array: true
+ t.index ["design_id", "note_id"], name: "design_user_mentions_on_design_id_and_note_id_index"
+ t.index ["note_id"], name: "index_design_user_mentions_on_note_id", unique: true
+ end
+
create_table "draft_notes", force: :cascade do |t|
t.integer "merge_request_id", null: false
t.integer "author_id", null: false
@@ -1418,10 +1466,11 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.string "environment_type"
t.string "state", default: "available", null: false
t.string "slug", null: false
+ t.datetime_with_timezone "auto_stop_at"
t.index ["name"], name: "index_environments_on_name_varchar_pattern_ops", opclass: :varchar_pattern_ops
t.index ["project_id", "name"], name: "index_environments_on_project_id_and_name", unique: true
t.index ["project_id", "slug"], name: "index_environments_on_project_id_and_slug", unique: true
- t.index ["project_id", "state"], name: "index_environments_on_project_id_and_state"
+ t.index ["project_id", "state", "environment_type"], name: "index_environments_on_project_id_state_environment_type"
end
create_table "epic_issues", id: :serial, force: :cascade do |t|
@@ -1439,6 +1488,17 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["epic_id"], name: "index_epic_metrics"
end
+ create_table "epic_user_mentions", force: :cascade do |t|
+ t.integer "epic_id", null: false
+ t.integer "note_id"
+ t.integer "mentioned_users_ids", array: true
+ t.integer "mentioned_projects_ids", array: true
+ t.integer "mentioned_groups_ids", array: true
+ t.index ["epic_id", "note_id"], name: "epic_user_mentions_on_epic_id_and_note_id_index", unique: true
+ t.index ["epic_id"], name: "epic_user_mentions_on_epic_id_index", unique: true, where: "(note_id IS NULL)"
+ t.index ["note_id"], name: "index_epic_user_mentions_on_note_id", unique: true, where: "(note_id IS NOT NULL)"
+ end
+
create_table "epics", id: :serial, force: :cascade do |t|
t.integer "milestone_id"
t.integer "group_id", null: false
@@ -1620,6 +1680,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.text "new_wiki_disk_path", null: false
t.integer "old_storage_version", limit: 2
t.integer "new_storage_version", limit: 2, null: false
+ t.text "old_design_disk_path"
+ t.text "new_design_disk_path"
t.index ["project_id"], name: "index_geo_hashed_storage_migrated_events_on_project_id"
end
@@ -1790,6 +1852,24 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["upload_id"], name: "index_geo_upload_deleted_events_on_upload_id"
end
+ create_table "gitlab_subscription_histories", force: :cascade do |t|
+ t.datetime_with_timezone "gitlab_subscription_created_at"
+ t.datetime_with_timezone "gitlab_subscription_updated_at"
+ t.date "start_date"
+ t.date "end_date"
+ t.date "trial_ends_on"
+ t.integer "namespace_id"
+ t.integer "hosted_plan_id"
+ t.integer "max_seats_used"
+ t.integer "seats"
+ t.boolean "trial"
+ t.integer "change_type", limit: 2
+ t.bigint "gitlab_subscription_id", null: false
+ t.datetime_with_timezone "created_at"
+ t.date "trial_starts_on"
+ t.index ["gitlab_subscription_id"], name: "index_gitlab_subscription_histories_on_gitlab_subscription_id"
+ end
+
create_table "gitlab_subscriptions", force: :cascade do |t|
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
@@ -1801,6 +1881,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "max_seats_used", default: 0
t.integer "seats", default: 0
t.boolean "trial", default: false
+ t.date "trial_starts_on"
t.index ["hosted_plan_id"], name: "index_gitlab_subscriptions_on_hosted_plan_id"
t.index ["namespace_id"], name: "index_gitlab_subscriptions_on_namespace_id", unique: true
end
@@ -1852,6 +1933,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
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 ["enabled"], name: "index_grafana_integrations_on_enabled", where: "(enabled IS TRUE)"
t.index ["project_id"], name: "index_grafana_integrations_on_project_id"
end
@@ -1865,6 +1947,13 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["key", "value"], name: "index_group_custom_attributes_on_key_and_value"
end
+ create_table "group_deletion_schedules", primary_key: "group_id", id: :bigint, default: nil, force: :cascade do |t|
+ t.bigint "user_id", null: false
+ t.date "marked_for_deletion_on", null: false
+ t.index ["marked_for_deletion_on"], name: "index_group_deletion_schedules_on_marked_for_deletion_on"
+ t.index ["user_id"], name: "index_group_deletion_schedules_on_user_id"
+ 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
@@ -1907,6 +1996,18 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["updated_at"], name: "index_import_export_uploads_on_updated_at"
end
+ create_table "import_failures", force: :cascade do |t|
+ t.integer "relation_index"
+ t.bigint "project_id", null: false
+ t.datetime_with_timezone "created_at", null: false
+ t.string "relation_key", limit: 64
+ t.string "exception_class", limit: 128
+ t.string "correlation_id_value", limit: 128
+ t.string "exception_message", limit: 255
+ t.index ["correlation_id_value"], name: "index_import_failures_on_correlation_id_value"
+ t.index ["project_id"], name: "index_import_failures_on_project_id"
+ end
+
create_table "index_statuses", id: :serial, force: :cascade do |t|
t.integer "project_id", null: false
t.datetime "indexed_at"
@@ -1955,6 +2056,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "target_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
+ t.integer "link_type", limit: 2, default: 0, null: false
t.index ["source_id", "target_id"], name: "index_issue_links_on_source_id_and_target_id", unique: true
t.index ["source_id"], name: "index_issue_links_on_source_id"
t.index ["target_id"], name: "index_issue_links_on_target_id"
@@ -1984,6 +2086,17 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["service_id"], name: "index_issue_tracker_data_on_service_id"
end
+ create_table "issue_user_mentions", force: :cascade do |t|
+ t.integer "issue_id", null: false
+ t.integer "note_id"
+ t.integer "mentioned_users_ids", array: true
+ t.integer "mentioned_projects_ids", array: true
+ t.integer "mentioned_groups_ids", array: true
+ t.index ["issue_id", "note_id"], name: "issue_user_mentions_on_issue_id_and_note_id_index", unique: true
+ t.index ["issue_id"], name: "issue_user_mentions_on_issue_id_index", unique: true, where: "(note_id IS NULL)"
+ t.index ["note_id"], name: "index_issue_user_mentions_on_note_id", unique: true, where: "(note_id IS NOT NULL)"
+ end
+
create_table "issues", id: :serial, force: :cascade do |t|
t.string "title"
t.integer "author_id"
@@ -2013,6 +2126,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "closed_by_id"
t.integer "state_id", limit: 2, default: 1, null: false
t.integer "duplicated_to_id"
+ t.integer "promoted_to_epic_id"
t.index ["author_id"], name: "index_issues_on_author_id"
t.index ["closed_by_id"], name: "index_issues_on_closed_by_id"
t.index ["confidential"], name: "index_issues_on_confidential"
@@ -2029,6 +2143,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["project_id", "relative_position", "state_id", "id"], name: "idx_issues_on_project_id_and_rel_position_and_state_id_and_id", order: { id: :desc }
t.index ["project_id", "updated_at", "id", "state"], name: "index_issues_on_project_id_and_updated_at_and_id_and_state"
t.index ["project_id", "updated_at", "id", "state_id"], name: "idx_issues_on_project_id_and_updated_at_and_id_and_state_id"
+ t.index ["promoted_to_epic_id"], name: "index_issues_on_promoted_to_epic_id", where: "(promoted_to_epic_id IS NOT NULL)"
t.index ["relative_position"], name: "index_issues_on_relative_position"
t.index ["state"], name: "index_issues_on_state"
t.index ["state_id"], name: "idx_issues_on_state_id"
@@ -2099,8 +2214,11 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.string "fingerprint"
t.boolean "public", default: false, null: false
t.datetime "last_used_at"
+ t.binary "fingerprint_sha256"
t.index ["fingerprint"], name: "index_keys_on_fingerprint", unique: true
+ t.index ["fingerprint_sha256"], name: "index_keys_on_fingerprint_sha256"
t.index ["id", "type"], name: "index_on_deploy_keys_id_and_type_and_public", unique: true, where: "(public = true)"
+ t.index ["last_used_at"], name: "index_keys_on_last_used_at", order: "DESC NULLS LAST"
t.index ["user_id"], name: "index_keys_on_user_id"
end
@@ -2138,6 +2256,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "group_id"
t.integer "cached_markdown_version"
t.index ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true
+ t.index ["group_id", "title"], name: "index_labels_on_group_id_and_title", where: "(project_id = NULL::integer)"
+ t.index ["project_id", "title"], name: "index_labels_on_project_id_and_title", where: "(group_id = NULL::integer)"
t.index ["project_id"], name: "index_labels_on_project_id"
t.index ["template"], name: "index_labels_on_template", where: "template"
t.index ["title"], name: "index_labels_on_title"
@@ -2211,6 +2331,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "user_id"
t.integer "milestone_id"
t.integer "max_issue_count", default: 0, null: false
+ t.integer "max_issue_weight", default: 0, null: false
t.index ["board_id", "label_id"], name: "index_lists_on_board_id_and_label_id", unique: true
t.index ["label_id"], name: "index_lists_on_label_id"
t.index ["list_type"], name: "index_lists_on_list_type"
@@ -2339,6 +2460,17 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id"
end
+ create_table "merge_request_user_mentions", force: :cascade do |t|
+ t.integer "merge_request_id", null: false
+ t.integer "note_id"
+ t.integer "mentioned_users_ids", array: true
+ t.integer "mentioned_projects_ids", array: true
+ t.integer "mentioned_groups_ids", array: true
+ t.index ["merge_request_id", "note_id"], name: "merge_request_user_mentions_on_mr_id_and_note_id_index", unique: true
+ t.index ["merge_request_id"], name: "merge_request_user_mentions_on_mr_id_index", unique: true, where: "(note_id IS NULL)"
+ t.index ["note_id"], name: "index_merge_request_user_mentions_on_note_id", unique: true, where: "(note_id IS NOT NULL)"
+ end
+
create_table "merge_requests", id: :serial, force: :cascade do |t|
t.string "target_branch", null: false
t.string "source_branch", null: false
@@ -2424,9 +2556,10 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.datetime_with_timezone "updated_at", null: false
t.integer "target_project_id", null: false
t.text "target_branch", null: false
+ t.integer "status", limit: 2, default: 0, null: false
t.index ["merge_request_id"], name: "index_merge_trains_on_merge_request_id", unique: true
t.index ["pipeline_id"], name: "index_merge_trains_on_pipeline_id"
- t.index ["target_project_id"], name: "index_merge_trains_on_target_project_id"
+ t.index ["target_project_id", "target_branch", "status"], name: "index_for_status_per_branch_per_project"
t.index ["user_id"], name: "index_merge_trains_on_user_id"
end
@@ -2523,6 +2656,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.boolean "emails_disabled"
t.integer "max_pages_size"
t.integer "max_artifacts_size"
+ t.boolean "mentions_disabled"
t.index ["created_at"], name: "index_namespaces_on_created_at"
t.index ["custom_project_templates_group_id", "type"], name: "index_namespaces_on_custom_project_templates_group_id_and_type", where: "(custom_project_templates_group_id IS NOT NULL)"
t.index ["file_template_project_id"], name: "index_namespaces_on_file_template_project_id"
@@ -2692,12 +2826,17 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
create_table "operations_feature_flags_clients", force: :cascade do |t|
t.integer "project_id", null: false
- t.string "token"
t.string "token_encrypted"
- t.index ["project_id", "token"], name: "index_operations_feature_flags_clients_on_project_id_and_token", unique: true
t.index ["project_id", "token_encrypted"], name: "index_feature_flags_clients_on_project_id_and_token_encrypted", unique: true
end
+ create_table "packages_build_infos", force: :cascade do |t|
+ t.integer "package_id", null: false
+ t.integer "pipeline_id"
+ t.index ["package_id"], name: "index_packages_build_infos_on_package_id", unique: true
+ t.index ["pipeline_id"], name: "index_packages_build_infos_on_pipeline_id"
+ 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
@@ -2718,6 +2857,20 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["package_id"], name: "index_packages_conan_metadata_on_package_id", unique: true
end
+ create_table "packages_dependencies", force: :cascade do |t|
+ t.string "name", limit: 255, null: false
+ t.string "version_pattern", limit: 255, null: false
+ t.index ["name", "version_pattern"], name: "index_packages_dependencies_on_name_and_version_pattern", unique: true
+ end
+
+ create_table "packages_dependency_links", force: :cascade do |t|
+ t.bigint "package_id", null: false
+ t.bigint "dependency_id", null: false
+ t.integer "dependency_type", limit: 2, null: false
+ t.index ["dependency_id"], name: "index_packages_dependency_links_on_dependency_id"
+ t.index ["package_id", "dependency_id", "dependency_type"], name: "idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type", 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
@@ -2743,12 +2896,6 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["package_id", "file_name"], name: "index_packages_package_files_on_package_id_and_file_name"
end
- create_table "packages_package_metadata", force: :cascade do |t|
- t.integer "package_id", null: false
- t.binary "metadata", null: false
- t.index ["package_id"], name: "index_packages_package_metadata_on_package_id", unique: true
- end
-
create_table "packages_package_tags", force: :cascade do |t|
t.integer "package_id", null: false
t.string "name", limit: 255, null: false
@@ -2763,6 +2910,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.string "version"
t.integer "package_type", limit: 2, null: false
t.index ["name"], name: "index_packages_packages_on_name_trigram", opclass: :gin_trgm_ops, using: :gin
+ t.index ["project_id", "name", "version", "package_type"], name: "idx_packages_packages_on_project_id_name_version_package_type"
t.index ["project_id"], name: "index_packages_packages_on_project_id"
end
@@ -2795,13 +2943,17 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.datetime_with_timezone "certificate_valid_not_before"
t.datetime_with_timezone "certificate_valid_not_after"
t.integer "certificate_source", limit: 2, default: 0, null: false
+ t.boolean "wildcard", default: false, null: false
+ t.integer "domain_type", limit: 2, default: 2, null: false
t.index ["certificate_source", "certificate_valid_not_after"], name: "index_pages_domains_need_auto_ssl_renewal", where: "(auto_ssl_enabled = true)"
t.index ["domain"], name: "index_pages_domains_on_domain", unique: true
+ t.index ["domain_type"], name: "index_pages_domains_on_domain_type"
t.index ["project_id", "enabled_until"], name: "index_pages_domains_on_project_id_and_enabled_until"
t.index ["project_id"], name: "index_pages_domains_on_project_id"
t.index ["remove_at"], name: "index_pages_domains_on_remove_at"
t.index ["verified_at", "enabled_until"], name: "index_pages_domains_on_verified_at_and_enabled_until"
t.index ["verified_at"], name: "index_pages_domains_on_verified_at"
+ t.index ["wildcard"], name: "index_pages_domains_on_wildcard"
end
create_table "path_locks", id: :serial, force: :cascade do |t|
@@ -2825,7 +2977,9 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.string "scopes", default: "--- []\n", null: false
t.boolean "impersonation", default: false, null: false
t.string "token_digest"
+ t.boolean "expire_notification_delivered", default: false, null: false
t.index ["token_digest"], name: "index_personal_access_tokens_on_token_digest", unique: true
+ t.index ["user_id", "expires_at"], name: "index_pat_on_user_id_and_expires_at"
t.index ["user_id"], name: "index_personal_access_tokens_on_user_id"
end
@@ -2834,6 +2988,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
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.integer "project_hooks", default: 0, null: false
t.index ["plan_id"], name: "index_plan_limits_on_plan_id", unique: true
end
@@ -2852,7 +3007,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "source_project_id"
t.index ["disk_path"], name: "index_pool_repositories_on_disk_path", unique: true
t.index ["shard_id"], name: "index_pool_repositories_on_shard_id"
- t.index ["source_project_id"], name: "index_pool_repositories_on_source_project_id", unique: true
+ t.index ["source_project_id", "shard_id"], name: "index_pool_repositories_on_source_project_id_and_shard_id", unique: true
end
create_table "programming_languages", id: :serial, force: :cascade do |t|
@@ -3137,7 +3292,6 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.bigint "pool_repository_id"
t.string "runners_token_encrypted"
t.string "bfg_object_map"
- t.boolean "merge_requests_require_code_owner_approval"
t.boolean "detected_repository_languages"
t.boolean "merge_requests_disable_committers_approval"
t.boolean "require_password_to_approve"
@@ -3149,7 +3303,6 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
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", "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
@@ -3420,7 +3573,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.text "reference_html"
t.index ["epic_id"], name: "index_resource_label_events_on_epic_id"
t.index ["issue_id"], name: "index_resource_label_events_on_issue_id"
- t.index ["label_id"], name: "index_resource_label_events_on_label_id"
+ t.index ["label_id", "action"], name: "index_resource_label_events_on_label_id_and_action"
t.index ["merge_request_id"], name: "index_resource_label_events_on_merge_request_id"
t.index ["user_id"], name: "index_resource_label_events_on_user_id"
end
@@ -3492,6 +3645,28 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true
end
+ create_table "sentry_issues", force: :cascade do |t|
+ t.bigint "issue_id", null: false
+ t.bigint "sentry_issue_identifier", null: false
+ t.index ["issue_id"], name: "index_sentry_issues_on_issue_id", unique: true
+ end
+
+ create_table "serverless_domain_cluster", primary_key: "uuid", id: :string, limit: 14, force: :cascade do |t|
+ t.bigint "pages_domain_id", null: false
+ t.bigint "clusters_applications_knative_id", null: false
+ t.bigint "creator_id"
+ t.datetime_with_timezone "created_at", null: false
+ t.datetime_with_timezone "updated_at", null: false
+ t.index ["clusters_applications_knative_id"], name: "idx_serverless_domain_cluster_on_clusters_applications_knative", unique: true
+ t.index ["creator_id"], name: "index_serverless_domain_cluster_on_creator_id"
+ t.index ["pages_domain_id"], name: "index_serverless_domain_cluster_on_pages_domain_id"
+ end
+
+ create_table "service_desk_settings", primary_key: "project_id", id: :bigint, default: nil, force: :cascade do |t|
+ t.string "issue_template_key", limit: 255
+ t.string "outgoing_name", limit: 255
+ end
+
create_table "services", id: :serial, force: :cascade do |t|
t.string "type"
t.string "title"
@@ -3516,6 +3691,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.boolean "confidential_note_events", default: true
t.boolean "deployment_events", default: false, null: false
t.string "description", limit: 500
+ t.boolean "comment_on_event_enabled", default: true, null: false
t.index ["project_id"], name: "index_services_on_project_id"
t.index ["template"], name: "index_services_on_template"
t.index ["type"], name: "index_services_on_type"
@@ -3546,6 +3722,17 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.index ["user_id"], name: "index_smartcard_identities_on_user_id"
end
+ create_table "snippet_user_mentions", force: :cascade do |t|
+ t.integer "snippet_id", null: false
+ t.integer "note_id"
+ t.integer "mentioned_users_ids", array: true
+ t.integer "mentioned_projects_ids", array: true
+ t.integer "mentioned_groups_ids", array: true
+ t.index ["note_id"], name: "index_snippet_user_mentions_on_note_id", unique: true, where: "(note_id IS NOT NULL)"
+ t.index ["snippet_id", "note_id"], name: "snippet_user_mentions_on_snippet_id_and_note_id_index", unique: true
+ t.index ["snippet_id"], name: "snippet_user_mentions_on_snippet_id_index", unique: true, where: "(note_id IS NULL)"
+ end
+
create_table "snippets", id: :serial, force: :cascade do |t|
t.string "title"
t.text "content"
@@ -3561,19 +3748,23 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.integer "cached_markdown_version"
t.text "description"
t.text "description_html"
+ t.string "encrypted_secret_token", limit: 255
+ t.string "encrypted_secret_token_iv", limit: 255
+ t.boolean "secret", default: false, null: false
t.index ["author_id"], name: "index_snippets_on_author_id"
t.index ["content"], name: "index_snippets_on_content_trigram", opclass: :gin_trgm_ops, using: :gin
+ t.index ["created_at"], name: "index_snippets_on_created_at"
t.index ["file_name"], name: "index_snippets_on_file_name_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["project_id", "visibility_level"], name: "index_snippets_on_project_id_and_visibility_level"
t.index ["title"], name: "index_snippets_on_title_trigram", opclass: :gin_trgm_ops, using: :gin
t.index ["updated_at"], name: "index_snippets_on_updated_at"
- t.index ["visibility_level"], name: "index_snippets_on_visibility_level"
+ t.index ["visibility_level", "secret"], name: "index_snippets_on_visibility_level_and_secret"
end
create_table "software_license_policies", id: :serial, force: :cascade do |t|
t.integer "project_id", null: false
t.integer "software_license_id", null: false
- t.integer "approval_status", default: 0, null: false
+ t.integer "classification", default: 0, null: false
t.index ["project_id", "software_license_id"], name: "index_software_license_policies_unique_per_project", unique: true
t.index ["software_license_id"], name: "index_software_license_policies_on_software_license_id"
end
@@ -3581,7 +3772,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
create_table "software_licenses", id: :serial, force: :cascade do |t|
t.string "name", null: false
t.string "spdx_identifier", limit: 255
- t.index ["name"], name: "index_software_licenses_on_name"
+ t.index ["name"], name: "index_software_licenses_on_unique_name", unique: true
t.index ["spdx_identifier"], name: "index_software_licenses_on_spdx_identifier"
end
@@ -3677,6 +3868,7 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
t.datetime "spent_at"
t.index ["issue_id"], name: "index_timelogs_on_issue_id"
t.index ["merge_request_id"], name: "index_timelogs_on_merge_request_id"
+ t.index ["spent_at"], name: "index_timelogs_on_spent_at", where: "(spent_at IS NOT NULL)"
t.index ["user_id"], name: "index_timelogs_on_user_id"
end
@@ -4264,6 +4456,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
add_foreign_key "clusters_kubernetes_namespaces", "clusters", on_delete: :cascade
add_foreign_key "clusters_kubernetes_namespaces", "environments", on_delete: :nullify
add_foreign_key "clusters_kubernetes_namespaces", "projects", on_delete: :nullify
+ add_foreign_key "commit_user_mentions", "notes", on_delete: :cascade
+ add_foreign_key "container_expiration_policies", "projects", on_delete: :cascade
add_foreign_key "container_repositories", "projects"
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
@@ -4281,6 +4475,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
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", column: "author_id", name: "fk_c1440b4896", on_delete: :nullify
+ add_foreign_key "design_user_mentions", "design_management_designs", column: "design_id", on_delete: :cascade
+ add_foreign_key "design_user_mentions", "notes", on_delete: :cascade
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
@@ -4289,6 +4485,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) 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 "epic_user_mentions", "epics", on_delete: :cascade
+ add_foreign_key "epic_user_mentions", "notes", 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
@@ -4339,6 +4537,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) 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_deletion_schedules", "namespaces", column: "group_id", on_delete: :cascade
+ add_foreign_key "group_deletion_schedules", "users", name: "fk_11e3ebfcdd", on_delete: :cascade
add_foreign_key "group_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
@@ -4356,6 +4556,9 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
add_foreign_key "issue_links", "issues", column: "target_id", name: "fk_e71bb44f1f", on_delete: :cascade
add_foreign_key "issue_metrics", "issues", on_delete: :cascade
add_foreign_key "issue_tracker_data", "services", on_delete: :cascade
+ add_foreign_key "issue_user_mentions", "issues", on_delete: :cascade
+ add_foreign_key "issue_user_mentions", "notes", on_delete: :cascade
+ add_foreign_key "issues", "epics", column: "promoted_to_epic_id", name: "fk_df75a7c8b8", on_delete: :nullify
add_foreign_key "issues", "issues", column: "duplicated_to_id", name: "fk_9c4516d665", on_delete: :nullify
add_foreign_key "issues", "issues", column: "moved_to_id", name: "fk_a194299be1", on_delete: :nullify
add_foreign_key "issues", "milestones", name: "fk_96b1dd429c", on_delete: :nullify
@@ -4395,6 +4598,8 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
add_foreign_key "merge_request_metrics", "merge_requests", on_delete: :cascade
add_foreign_key "merge_request_metrics", "users", column: "latest_closed_by_id", name: "fk_ae440388cc", on_delete: :nullify
add_foreign_key "merge_request_metrics", "users", column: "merged_by_id", name: "fk_7f28d925f3", on_delete: :nullify
+ add_foreign_key "merge_request_user_mentions", "merge_requests", on_delete: :cascade
+ add_foreign_key "merge_request_user_mentions", "notes", on_delete: :cascade
add_foreign_key "merge_requests", "ci_pipelines", column: "head_pipeline_id", name: "fk_fd82eae0b9", on_delete: :nullify
add_foreign_key "merge_requests", "merge_request_diffs", column: "latest_merge_request_diff_id", name: "fk_06067f5644", on_delete: :nullify
add_foreign_key "merge_requests", "milestones", name: "fk_6a5165a692", on_delete: :nullify
@@ -4424,15 +4629,18 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
add_foreign_key "notes", "projects", name: "fk_99e097b079", on_delete: :cascade
add_foreign_key "notes", "reviews", name: "fk_2e82291620", on_delete: :nullify
add_foreign_key "notification_settings", "users", name: "fk_0c95e91db7", on_delete: :cascade
- add_foreign_key "oauth_openid_requests", "oauth_access_grants", column: "access_grant_id", name: "fk_oauth_openid_requests_oauth_access_grants_access_grant_id"
+ add_foreign_key "oauth_openid_requests", "oauth_access_grants", column: "access_grant_id", name: "fk_77114b3b09", on_delete: :cascade
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_build_infos", "ci_pipelines", column: "pipeline_id", on_delete: :nullify
+ add_foreign_key "packages_build_infos", "packages_packages", column: "package_id", on_delete: :cascade
add_foreign_key "packages_conan_file_metadata", "packages_package_files", column: "package_file_id", on_delete: :cascade
add_foreign_key "packages_conan_metadata", "packages_packages", column: "package_id", on_delete: :cascade
+ add_foreign_key "packages_dependency_links", "packages_dependencies", column: "dependency_id", on_delete: :cascade
+ add_foreign_key "packages_dependency_links", "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
add_foreign_key "packages_package_tags", "packages_packages", column: "package_id", on_delete: :cascade
add_foreign_key "packages_packages", "projects", on_delete: :cascade
add_foreign_key "pages_domain_acme_orders", "pages_domains", on_delete: :cascade
@@ -4512,9 +4720,16 @@ ActiveRecord::Schema.define(version: 2019_11_22_135327) do
add_foreign_key "scim_oauth_access_tokens", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "self_managed_prometheus_alert_events", "environments", on_delete: :cascade
add_foreign_key "self_managed_prometheus_alert_events", "projects", on_delete: :cascade
+ add_foreign_key "sentry_issues", "issues", on_delete: :cascade
+ add_foreign_key "serverless_domain_cluster", "clusters_applications_knative", on_delete: :cascade
+ add_foreign_key "serverless_domain_cluster", "pages_domains", on_delete: :cascade
+ add_foreign_key "serverless_domain_cluster", "users", column: "creator_id", on_delete: :nullify
+ add_foreign_key "service_desk_settings", "projects", on_delete: :cascade
add_foreign_key "services", "projects", name: "fk_71cce407f9", on_delete: :cascade
add_foreign_key "slack_integrations", "services", on_delete: :cascade
add_foreign_key "smartcard_identities", "users", on_delete: :cascade
+ add_foreign_key "snippet_user_mentions", "notes", on_delete: :cascade
+ add_foreign_key "snippet_user_mentions", "snippets", on_delete: :cascade
add_foreign_key "snippets", "projects", name: "fk_be41fd4bb7", on_delete: :cascade
add_foreign_key "software_license_policies", "projects", on_delete: :cascade
add_foreign_key "software_license_policies", "software_licenses", on_delete: :cascade