Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 17:02:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 17:02:45 +0300
commit80f61b4035607d7cd87de993b8f5e996bde3481f (patch)
tree06b12f51e97d87192e3dd0e05edf55143645b894 /db
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/development/02_application_settings.rb2
-rw-r--r--db/fixtures/development/10_merge_requests.rb2
-rw-r--r--db/fixtures/development/24_forks.rb9
-rw-r--r--db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb2
-rw-r--r--db/migrate/20190801193427_rename_application_settings_snowplow_collector_uri_column.rb2
-rw-r--r--db/migrate/20190918104212_add_merge_request_metrics_merged_at_index.rb17
-rw-r--r--db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb2
-rw-r--r--db/post_migrate/20180305100050_remove_permanent_from_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/20190214112022_schedule_sync_issuables_state_id.rb2
-rw-r--r--db/post_migrate/20190506135400_schedule_sync_issuables_state_id_where_nil.rb2
-rw-r--r--db/post_migrate/20190802091750_cleanup_application_settings_snowplow_collector_uri_rename.rb2
-rw-r--r--db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb31
-rw-r--r--db/schema.rb3
16 files changed, 71 insertions, 17 deletions
diff --git a/db/fixtures/development/02_application_settings.rb b/db/fixtures/development/02_application_settings.rb
index 7cdc8e40b69..67486d2ab5f 100644
--- a/db/fixtures/development/02_application_settings.rb
+++ b/db/fixtures/development/02_application_settings.rb
@@ -3,7 +3,7 @@
puts "Creating the default ApplicationSetting record.".color(:green)
ApplicationSetting.create_from_defaults
-# Details https://gitlab.com/gitlab-org/gitlab-ce/issues/46241
+# Details https://gitlab.com/gitlab-org/gitlab-foss/issues/46241
puts "Enable hashed storage for every new projects.".color(:green)
ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true)
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 43b69470d2c..4af545614f7 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -33,7 +33,7 @@ Gitlab::Seeder.quiet do
MergeRequests::CreateService.new(project, developer, params).execute
rescue Repository::AmbiguousRefError
# Ignore pipelines creation errors for now, we can doing that after
- # https://gitlab.com/gitlab-org/gitlab-ce/issues/55966. will be resolved.
+ # https://gitlab.com/gitlab-org/gitlab-foss/issues/55966. will be resolved.
end
print '.'
end
diff --git a/db/fixtures/development/24_forks.rb b/db/fixtures/development/24_forks.rb
index d05d27c3ed5..971c6f0d0c8 100644
--- a/db/fixtures/development/24_forks.rb
+++ b/db/fixtures/development/24_forks.rb
@@ -6,11 +6,16 @@ Sidekiq::Testing.inline! do
source_project = Project.public_only.sample
##
- # 04_project.rb might not have created a public project because
+ # 03_project.rb might not have created a public project because
# we use randomized approach (e.g. `Array#sample`).
return unless source_project
- fork_project = Projects::ForkService.new(source_project, user, namespace: user.namespace).execute
+ fork_project = Projects::ForkService.new(
+ source_project,
+ user,
+ namespace: user.namespace,
+ skip_disk_validation: true
+ ).execute
if fork_project.valid?
print '.'
diff --git a/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb b/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb
index 8de8b3bcc2e..21d7f50ee83 100644
--- a/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb
+++ b/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb
@@ -6,7 +6,7 @@ class CreateMissingNamespaceForInternalUsers < ActiveRecord::Migration[4.2]
create_namespace(id, username)
# When testing locally I've noticed that these internal users are missing
# the notification email, for more details visit the below link:
- # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18357#note_68327560
+ # https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/18357#note_68327560
set_notification_email(id)
end
end
diff --git a/db/migrate/20190801193427_rename_application_settings_snowplow_collector_uri_column.rb b/db/migrate/20190801193427_rename_application_settings_snowplow_collector_uri_column.rb
index a4bd5841a46..fba9849d3eb 100644
--- a/db/migrate/20190801193427_rename_application_settings_snowplow_collector_uri_column.rb
+++ b/db/migrate/20190801193427_rename_application_settings_snowplow_collector_uri_column.rb
@@ -12,6 +12,6 @@ class RenameApplicationSettingsSnowplowCollectorUriColumn < ActiveRecord::Migrat
end
def down
- cleanup_concurrent_column_rename :application_settings, :snowplow_collector_hostname, :snowplow_collector_uri
+ undo_rename_column_concurrently :application_settings, :snowplow_collector_uri, :snowplow_collector_hostname
end
end
diff --git a/db/migrate/20190918104212_add_merge_request_metrics_merged_at_index.rb b/db/migrate/20190918104212_add_merge_request_metrics_merged_at_index.rb
new file mode 100644
index 00000000000..9db4e42f3ee
--- /dev/null
+++ b/db/migrate/20190918104212_add_merge_request_metrics_merged_at_index.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddMergeRequestMetricsMergedAtIndex < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :merge_request_metrics, [:merged_at, :id]
+ end
+
+ def down
+ remove_concurrent_index :merge_request_metrics, [:merged_at, :id]
+ end
+end
diff --git a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
index 0a2ea7bfb7b..88b713aaef3 100644
--- a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
+++ b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
@@ -16,7 +16,7 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration[4.2]
Failed to add an unique index to ci_stages, despite retrying the
migration 100 times.
- See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16580.
+ See https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/16580.
EOS
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 15c052da99b..3b3cb4267d4 100644
--- a/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
+++ b/db/post_migrate/20180305100050_remove_permanent_from_redirect_routes.rb
@@ -13,7 +13,7 @@ class RemovePermanentFromRedirectRoutes < ActiveRecord::Migration[4.2]
def up
# These indexes were created on Postgres only in:
# ReworkRedirectRoutesIndexes:
- # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16211
+ # 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};"
diff --git a/db/post_migrate/20180706223200_populate_site_statistics.rb b/db/post_migrate/20180706223200_populate_site_statistics.rb
index 896965b708f..0859aa88866 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-ce/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # 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-ce/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # 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 363219da539..9bf6aed833d 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-ce/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # 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 6d27eca38e3..7c1fca3884d 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-ce/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # 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-ce/issues/48967
+ execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # 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/20190214112022_schedule_sync_issuables_state_id.rb b/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb
index 6edb0bf2d5e..c05ad73d616 100644
--- a/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb
+++ b/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb
@@ -1,7 +1,7 @@
class ScheduleSyncIssuablesStateId < ActiveRecord::Migration[5.0]
# This migration schedules the sync of state_id for issues and merge requests
# which are converting the state column from string to integer.
- # For more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/51789
+ # For more information check: https://gitlab.com/gitlab-org/gitlab-foss/issues/51789
include Gitlab::Database::MigrationHelpers
diff --git a/db/post_migrate/20190506135400_schedule_sync_issuables_state_id_where_nil.rb b/db/post_migrate/20190506135400_schedule_sync_issuables_state_id_where_nil.rb
index 4c31b5968ff..cee99f7cf2e 100644
--- a/db/post_migrate/20190506135400_schedule_sync_issuables_state_id_where_nil.rb
+++ b/db/post_migrate/20190506135400_schedule_sync_issuables_state_id_where_nil.rb
@@ -4,7 +4,7 @@ class ScheduleSyncIssuablesStateIdWhereNil < ActiveRecord::Migration[5.1]
# Issues and MergeRequests imported by GitHub are being created with
# state_id = null, this fixes them.
#
- # Part of a bigger plan: https://gitlab.com/gitlab-org/gitlab-ce/issues/51789
+ # Part of a bigger plan: https://gitlab.com/gitlab-org/gitlab-foss/issues/51789
include Gitlab::Database::MigrationHelpers
diff --git a/db/post_migrate/20190802091750_cleanup_application_settings_snowplow_collector_uri_rename.rb b/db/post_migrate/20190802091750_cleanup_application_settings_snowplow_collector_uri_rename.rb
index 768ece925c6..77472585512 100644
--- a/db/post_migrate/20190802091750_cleanup_application_settings_snowplow_collector_uri_rename.rb
+++ b/db/post_migrate/20190802091750_cleanup_application_settings_snowplow_collector_uri_rename.rb
@@ -12,6 +12,6 @@ class CleanupApplicationSettingsSnowplowCollectorUriRename < ActiveRecord::Migra
end
def down
- rename_column_concurrently :application_settings, :snowplow_collector_hostname, :snowplow_collector_uri
+ undo_cleanup_concurrent_column_rename :application_settings, :snowplow_collector_uri, :snowplow_collector_hostname
end
end
diff --git a/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb b/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
new file mode 100644
index 00000000000..3e1c77ae992
--- /dev/null
+++ b/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class ScheduleProductivityAnalyticsBackfill < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ BATCH_SIZE = 10_000
+ INTERVAL = 3.minutes
+ MIGRATION = 'Gitlab::BackgroundMigration::RecalculateProductivityAnalytics'.freeze
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee?
+
+ metrics_model = Class.new(ActiveRecord::Base) do
+ self.table_name = 'merge_request_metrics'
+
+ include ::EachBatch
+ end
+
+ scope = metrics_model.where("merged_at >= ?", 3.months.ago)
+
+ queue_background_migration_jobs_by_range_at_intervals(scope, MIGRATION, INTERVAL, batch_size: BATCH_SIZE)
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b821951180a..09f27d2f9cb 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_09_14_223900) do
+ActiveRecord::Schema.define(version: 2019_09_18_104222) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@@ -2120,6 +2120,7 @@ ActiveRecord::Schema.define(version: 2019_09_14_223900) do
t.index ["latest_closed_by_id"], name: "index_merge_request_metrics_on_latest_closed_by_id"
t.index ["merge_request_id", "merged_at"], name: "index_merge_request_metrics_on_merge_request_id_and_merged_at", where: "(merged_at IS NOT NULL)"
t.index ["merge_request_id"], name: "index_merge_request_metrics"
+ t.index ["merged_at", "id"], name: "index_merge_request_metrics_on_merged_at_and_id"
t.index ["merged_by_id"], name: "index_merge_request_metrics_on_merged_by_id"
t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id"
end