From 52967b107b7b2f1472b4c005f70f21346079cd95 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 3 Apr 2018 11:00:33 +0000 Subject: Merge branch 'jej/mattermost-notification-confidentiality-10-6' into 'security-10-6' [10.6] Prevent notes on confidential issues from being sent to chat See merge request gitlab/gitlabhq!2366 # Conflicts: # app/helpers/services_helper.rb --- ...26_add_confidential_note_events_to_web_hooks.rb | 15 ++++++++++++++ ...548_add_confidential_note_events_to_services.rb | 16 +++++++++++++++ ...ule_set_confidential_note_events_on_webhooks.rb | 23 ++++++++++++++++++++++ ...ule_set_confidential_note_events_on_services.rb | 23 ++++++++++++++++++++++ db/schema.rb | 2 ++ 5 files changed, 79 insertions(+) create mode 100644 db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb create mode 100644 db/migrate/20180103123548_add_confidential_note_events_to_services.rb create mode 100644 db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb create mode 100644 db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb (limited to 'db') diff --git a/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb b/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb new file mode 100644 index 00000000000..900a6386922 --- /dev/null +++ b/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb @@ -0,0 +1,15 @@ +class AddConfidentialNoteEventsToWebHooks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column :web_hooks, :confidential_note_events, :boolean + end + + def down + remove_column :web_hooks, :confidential_note_events + end +end diff --git a/db/migrate/20180103123548_add_confidential_note_events_to_services.rb b/db/migrate/20180103123548_add_confidential_note_events_to_services.rb new file mode 100644 index 00000000000..b54ad88df43 --- /dev/null +++ b/db/migrate/20180103123548_add_confidential_note_events_to_services.rb @@ -0,0 +1,16 @@ +class AddConfidentialNoteEventsToServices < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column :services, :confidential_note_events, :boolean + change_column_default :services, :confidential_note_events, true + end + + def down + remove_column :services, :confidential_note_events + end +end diff --git a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb new file mode 100644 index 00000000000..fa51ac83619 --- /dev/null +++ b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb @@ -0,0 +1,23 @@ +class ScheduleSetConfidentialNoteEventsOnWebhooks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 1_000 + INTERVAL = 5.minutes + + disable_ddl_transaction! + + def up + migration = Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks + migration_name = migration.to_s.demodulize + relation = migration::WebHook.hooks_to_update + + queue_background_migration_jobs_by_range_at_intervals(relation, + migration_name, + INTERVAL, + batch_size: BATCH_SIZE) + end + + def down + end +end diff --git a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb new file mode 100644 index 00000000000..a3ff9f1719e --- /dev/null +++ b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb @@ -0,0 +1,23 @@ +class ScheduleSetConfidentialNoteEventsOnServices < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 1_000 + INTERVAL = 20.minutes + + disable_ddl_transaction! + + def up + migration = Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices + migration_name = migration.to_s.demodulize + relation = migration::Service.services_to_update + + queue_background_migration_jobs_by_range_at_intervals(relation, + migration_name, + INTERVAL, + batch_size: BATCH_SIZE) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 06fc1a9d7e9..25e7d720761 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1684,6 +1684,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do t.boolean "confidential_issues_events", default: true, null: false t.boolean "commit_events", default: true, null: false t.boolean "job_events", default: false, null: false + t.boolean "confidential_note_events", default: true end add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree @@ -2022,6 +2023,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do t.boolean "confidential_issues_events", default: false, null: false t.boolean "repository_update_events", default: false, null: false t.boolean "job_events", default: false, null: false + t.boolean "confidential_note_events" end add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree -- cgit v1.2.1 From dbee81480b6a2a88535a0b042012c9fbf287e32b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 5 Apr 2018 10:53:39 +0200 Subject: Reschedule pipeline stages migration to run it again --- ...0180212101928_schedule_build_stage_migration.rb | 25 ++++------------ ...405101928_reschedule_builds_stages_migration.rb | 33 ++++++++++++++++++++++ db/schema.rb | 2 +- 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb (limited to 'db') diff --git a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb index df15b2cd9d4..0f61fa81832 100644 --- a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb +++ b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb @@ -1,26 +1,11 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - MIGRATION = 'MigrateBuildStage'.freeze - BATCH_SIZE = 500 - - disable_ddl_transaction! - - class Build < ActiveRecord::Base - include EachBatch - self.table_name = 'ci_builds' - end + ## + # This migration has been rescheduled to run again, see + # `20180405101928_reschedule_builds_stages_migration.rb` + # def up - disable_statement_timeout - - Build.where('stage_id IS NULL').tap do |relation| - queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - 5.minutes, - batch_size: BATCH_SIZE) - end + # noop end def down diff --git a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb new file mode 100644 index 00000000000..e19387bce1e --- /dev/null +++ b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb @@ -0,0 +1,33 @@ +class RescheduleBuildsStagesMigration < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + ## + # Rescheduled `20180212101928_schedule_build_stage_migration.rb` + # + + DOWNTIME = false + MIGRATION = 'MigrateBuildStage'.freeze + BATCH_SIZE = 500 + + disable_ddl_transaction! + + class Build < ActiveRecord::Base + include EachBatch + self.table_name = 'ci_builds' + end + + def up + disable_statement_timeout + + Build.where('stage_id IS NULL').tap do |relation| + queue_background_migration_jobs_by_range_at_intervals(relation, + MIGRATION, + 5.minutes, + batch_size: BATCH_SIZE) + end + end + + def down + # noop + end +end diff --git a/db/schema.rb b/db/schema.rb index 06fc1a9d7e9..1dd87c12144 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180327101207) do +ActiveRecord::Schema.define(version: 20180405101928) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1