diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 12:07:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 12:07:33 +0000 |
commit | 6b75320f525f841454f1ab162d141d3610f2e77b (patch) | |
tree | 4971c27759e4fbc18b85e71800c3b9c12346317e /db | |
parent | 4226aca420920c1844e8eade4798a2dff188a6fc (diff) | |
download | gitlab-ce-6b75320f525f841454f1ab162d141d3610f2e77b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
5 files changed, 118 insertions, 0 deletions
diff --git a/db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb b/db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb new file mode 100644 index 00000000000..84befc95d00 --- /dev/null +++ b/db/migrate/20191008013056_add_push_event_activities_limit_to_application_settings.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddPushEventActivitiesLimitToApplicationSettings < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:application_settings, :push_event_activities_limit, :integer, default: 3) + end + + def down + remove_column(:application_settings, :push_event_activities_limit) + end +end diff --git a/db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb b/db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb new file mode 100644 index 00000000000..72621971dbb --- /dev/null +++ b/db/migrate/20191008142331_add_ref_count_to_push_event_payloads.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddRefCountToPushEventPayloads < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :push_event_payloads, :ref_count, :integer + end +end diff --git a/db/post_migrate/20191007163701_populate_remaining_any_approver_rules_for_merge_requests.rb b/db/post_migrate/20191007163701_populate_remaining_any_approver_rules_for_merge_requests.rb new file mode 100644 index 00000000000..e1c0f1d6c0c --- /dev/null +++ b/db/post_migrate/20191007163701_populate_remaining_any_approver_rules_for_merge_requests.rb @@ -0,0 +1,44 @@ +# 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 PopulateRemainingAnyApproverRulesForMergeRequests < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 10_000 + MIGRATION = 'PopulateAnyApprovalRuleForMergeRequests' + + disable_ddl_transaction! + + class MergeRequest < ActiveRecord::Base + include EachBatch + + self.table_name = 'merge_requests' + + scope :with_approvals_before_merge, -> { where.not(approvals_before_merge: 0) } + end + + def up + return unless Gitlab.ee? + + add_concurrent_index :merge_requests, :id, + name: 'tmp_merge_requests_with_approvals_before_merge', + where: 'approvals_before_merge != 0' + + Gitlab::BackgroundMigration.steal(MIGRATION) + + PopulateRemainingAnyApproverRulesForMergeRequests::MergeRequest.with_approvals_before_merge.each_batch(of: BATCH_SIZE) do |batch| + range = batch.pluck('MIN(id)', 'MAX(id)').first + + Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForMergeRequests.new.perform(*range) + end + + remove_concurrent_index_by_name(:merge_requests, 'tmp_merge_requests_with_approvals_before_merge') + end + + def down + # no-op + end +end diff --git a/db/post_migrate/20191007163736_populate_remaining_any_approver_rules_for_projects.rb b/db/post_migrate/20191007163736_populate_remaining_any_approver_rules_for_projects.rb new file mode 100644 index 00000000000..fce17ffcf16 --- /dev/null +++ b/db/post_migrate/20191007163736_populate_remaining_any_approver_rules_for_projects.rb @@ -0,0 +1,44 @@ +# 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 PopulateRemainingAnyApproverRulesForProjects < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 5_000 + MIGRATION = 'PopulateAnyApprovalRuleForProjects' + + disable_ddl_transaction! + + class Project < ActiveRecord::Base + include EachBatch + + self.table_name = 'projects' + + scope :with_approvals_before_merge, -> { where.not(approvals_before_merge: 0) } + end + + def up + return unless Gitlab.ee? + + add_concurrent_index :projects, :id, + name: 'tmp_projects_with_approvals_before_merge', + where: 'approvals_before_merge != 0' + + Gitlab::BackgroundMigration.steal(MIGRATION) + + PopulateRemainingAnyApproverRulesForProjects::Project.with_approvals_before_merge.each_batch(of: BATCH_SIZE) do |batch| + range = batch.pluck('MIN(id)', 'MAX(id)').first + + Gitlab::BackgroundMigration::PopulateAnyApprovalRuleForProjects.new.perform(*range) + end + + remove_concurrent_index_by_name(:projects, 'tmp_projects_with_approvals_before_merge') + end + + def down + # no-op + end +end diff --git a/db/schema.rb b/db/schema.rb index 50627fc9b06..825b66f6dfd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -339,6 +339,7 @@ ActiveRecord::Schema.define(version: 2019_10_16_072826) do t.integer "throttle_incident_management_notification_period_in_seconds", default: 3600 t.integer "throttle_incident_management_notification_per_period", default: 3600 t.integer "push_event_hooks_limit", default: 3, null: false + t.integer "push_event_activities_limit", default: 3, null: false t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id" t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id" t.index ["instance_administration_project_id"], name: "index_applicationsettings_on_instance_administration_project_id" @@ -3158,6 +3159,7 @@ ActiveRecord::Schema.define(version: 2019_10_16_072826) do t.binary "commit_to" t.text "ref" t.string "commit_title", limit: 70 + t.integer "ref_count" t.index ["event_id"], name: "index_push_event_payloads_on_event_id", unique: true end |