diff --git a/app/models/concerns/milestoneable.rb b/app/models/concerns/milestoneable.rb index 7fb3f95bf0a5c0eac2de3cd112cd5a1cb6ba6841..7df6981a1297f63b240f6ba29e1a00b9666ad234 100644 --- a/app/models/concerns/milestoneable.rb +++ b/app/models/concerns/milestoneable.rb @@ -14,8 +14,6 @@ module Milestoneable validate :milestone_is_valid - after_save :write_to_new_milestone_relationship - scope :of_milestones, ->(ids) { where(milestone_id: ids) } scope :any_milestone, -> { where('milestone_id IS NOT NULL') } scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: { title: title }) } @@ -41,10 +39,6 @@ module Milestoneable def milestone_is_valid errors.add(:milestone_id, message: "is invalid") if respond_to?(:milestone_id) && milestone_id.present? && !milestone_available? end - - def write_to_new_milestone_relationship - self.milestones = [milestone].compact if supports_milestone? && saved_change_to_milestone_id? - end end def milestone_available? diff --git a/app/models/issue.rb b/app/models/issue.rb index d01aa78a2c1f1d643de41c3aa17d1e57a4c6f9c3..be702134ced716a468fa749185c42ff14953f184 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -33,9 +33,6 @@ class Issue < ApplicationRecord has_internal_id :iid, scope: :project, track_if: -> { !importing? }, init: ->(s) { s&.project&.issues&.maximum(:iid) } - has_many :issue_milestones - has_many :milestones, through: :issue_milestones - has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :merge_requests_closing_issues, diff --git a/app/models/issue_milestone.rb b/app/models/issue_milestone.rb deleted file mode 100644 index da030077d8718ec11a727bc575004f6d46fef5c4..0000000000000000000000000000000000000000 --- a/app/models/issue_milestone.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class IssueMilestone < ApplicationRecord - belongs_to :milestone - belongs_to :issue -end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 14aa6ac066e5c40e0ab70b0789471e504df60704..6c32bdadfa889129d962e403f7bb1e918f93200d 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -38,9 +38,6 @@ class MergeRequest < ApplicationRecord has_many :merge_request_context_commits has_many :merge_request_context_commit_diff_files, through: :merge_request_context_commits, source: :diff_files - has_many :merge_request_milestones - has_many :milestones, through: :merge_request_milestones - has_one :merge_request_diff, -> { order('merge_request_diffs.id DESC') }, inverse_of: :merge_request diff --git a/app/models/merge_request_milestone.rb b/app/models/merge_request_milestone.rb deleted file mode 100644 index 4fa1d1dcb337864eb5e036fec79ee19b6b42dea2..0000000000000000000000000000000000000000 --- a/app/models/merge_request_milestone.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class MergeRequestMilestone < ApplicationRecord - belongs_to :milestone - belongs_to :merge_request -end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index b3278f48aa91efd61f8387fe2436f0a0847d4d9f..29c621c54d0fe9ecc5d0d13799106a88e3995356 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -39,9 +39,6 @@ class Milestone < ApplicationRecord has_many :merge_requests has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent - has_many :issue_milestones - has_many :merge_request_milestones - scope :of_projects, ->(ids) { where(project_id: ids) } scope :of_groups, ->(ids) { where(group_id: ids) } scope :active, -> { with_state(:active) } diff --git a/app/services/users/create_service.rb b/app/services/users/create_service.rb index 2ac6dfd90fa9d12e7c9b9d98a27ecc0c6d149304..ec8b3cea66487d5f0b20ad98cf46e7f5a630110e 100644 --- a/app/services/users/create_service.rb +++ b/app/services/users/create_service.rb @@ -11,12 +11,19 @@ module Users def execute(skip_authorization: false) user = Users::BuildService.new(current_user, params).execute(skip_authorization: skip_authorization) + reset_token = user.generate_reset_token if user.recently_sent_password_reset? - @reset_token = user.generate_reset_token if user.recently_sent_password_reset? - - notify_new_user(user, @reset_token) if user.save + after_create_hook(user, reset_token) if user.save user end + + private + + def after_create_hook(user, reset_token) + notify_new_user(user, reset_token) + end end end + +Users::CreateService.prepend_if_ee('EE::Users::CreateService') diff --git a/changelogs/unreleased/remove-multiple-milestone-mess.yml b/changelogs/unreleased/remove-multiple-milestone-mess.yml new file mode 100644 index 0000000000000000000000000000000000000000..cb888bff88da09509410e2128ecd9eb355d75f4d --- /dev/null +++ b/changelogs/unreleased/remove-multiple-milestone-mess.yml @@ -0,0 +1,5 @@ +--- +title: Remove unnecessary milestone join tables +merge_request: 25198 +author: +type: changed diff --git a/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb b/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb new file mode 100644 index 0000000000000000000000000000000000000000..19b3af53836f15bb289e38f4032c2dc08eba5922 --- /dev/null +++ b/db/post_migrate/20200213204737_remove_unnecessary_milestone_join_tables.rb @@ -0,0 +1,30 @@ +# 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 RemoveUnnecessaryMilestoneJoinTables < ActiveRecord::Migration[6.0] + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + drop_table :issue_milestones + drop_table :merge_request_milestones + end + + def down + create_table :issue_milestones, id: false do |t| + t.references :issue, foreign_key: { on_delete: :cascade }, index: { unique: true }, null: false + t.references :milestone, foreign_key: { on_delete: :cascade }, index: true, null: false + end + + add_index :issue_milestones, [:issue_id, :milestone_id], unique: true + + create_table :merge_request_milestones, id: false do |t| + t.references :merge_request, foreign_key: { on_delete: :cascade }, index: { unique: true }, null: false + t.references :milestone, foreign_key: { on_delete: :cascade }, index: true, null: false + end + + add_index :merge_request_milestones, [:merge_request_id, :milestone_id], name: 'index_mrs_milestones_on_mr_id_and_milestone_id', unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index fc30081cedf2c762b51bedc559d52d7315bfefec..178a5c299bcc0bb3eb29be3b5849c24ac6f3beec 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: 2020_02_12_052620) do +ActiveRecord::Schema.define(version: 2020_02_13_204737) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" @@ -2125,14 +2125,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.index ["issue_id"], name: "index_issue_metrics" end - create_table "issue_milestones", id: false, force: :cascade do |t| - t.bigint "issue_id", null: false - t.bigint "milestone_id", null: false - t.index ["issue_id", "milestone_id"], name: "index_issue_milestones_on_issue_id_and_milestone_id", unique: true - t.index ["issue_id"], name: "index_issue_milestones_on_issue_id", unique: true - t.index ["milestone_id"], name: "index_issue_milestones_on_milestone_id" - end - create_table "issue_tracker_data", force: :cascade do |t| t.integer "service_id", null: false t.datetime_with_timezone "created_at", null: false @@ -2552,14 +2544,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do t.index ["pipeline_id"], name: "index_merge_request_metrics_on_pipeline_id" end - create_table "merge_request_milestones", id: false, force: :cascade do |t| - t.bigint "merge_request_id", null: false - t.bigint "milestone_id", null: false - t.index ["merge_request_id", "milestone_id"], name: "index_mrs_milestones_on_mr_id_and_milestone_id", unique: true - t.index ["merge_request_id"], name: "index_merge_request_milestones_on_merge_request_id", unique: true - t.index ["milestone_id"], name: "index_merge_request_milestones_on_milestone_id" - end - create_table "merge_request_user_mentions", force: :cascade do |t| t.integer "merge_request_id", null: false t.integer "note_id" @@ -4799,8 +4783,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) do add_foreign_key "issue_links", "issues", column: "source_id", name: "fk_c900194ff2", on_delete: :cascade 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_milestones", "issues", on_delete: :cascade - add_foreign_key "issue_milestones", "milestones", 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 @@ -4846,8 +4828,6 @@ ActiveRecord::Schema.define(version: 2020_02_12_052620) 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_milestones", "merge_requests", on_delete: :cascade - add_foreign_key "merge_request_milestones", "milestones", on_delete: :cascade 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 diff --git a/doc/administration/audit_events.md b/doc/administration/audit_events.md index e46b74163f34faae4fc5edc8f915f9c933b5a428..fafd078c4878b8a6557af91f80ab1df4d43b1f77 100644 --- a/doc/administration/audit_events.md +++ b/doc/administration/audit_events.md @@ -107,6 +107,7 @@ recorded: - Started/stopped user impersonation - Changed username ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/7797) in GitLab 12.8) - User was deleted ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/251) in GitLab 12.8) +- User was added ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/251) in GitLab 12.8) - User was blocked via Admin Area ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/251) in GitLab 12.8) It is possible to filter particular actions by choosing an audit data type from diff --git a/doc/development/integrations/secure.md b/doc/development/integrations/secure.md index 469e81464471658a4622453ea05b5d62818a47e2..b230927a7deaba5b7a0166f1c409eccb514b08b1 100644 --- a/doc/development/integrations/secure.md +++ b/doc/development/integrations/secure.md @@ -61,7 +61,7 @@ and uploads it as a SAST report: ```yaml mysec_dependency_scanning: - image: regitry.gitlab.com/secure/mysec + image: registry.gitlab.com/secure/mysec artifacts: reports: sast: gl-sast-report.json diff --git a/doc/user/application_security/security_dashboard/img/instance_security_dashboard_with_projects_v12_7.png b/doc/user/application_security/security_dashboard/img/instance_security_dashboard_with_projects_v12_7.png deleted file mode 100644 index ffd6b0bfae61e05eeac91489798364ef4ac30d11..0000000000000000000000000000000000000000 Binary files a/doc/user/application_security/security_dashboard/img/instance_security_dashboard_with_projects_v12_7.png and /dev/null differ diff --git a/doc/user/application_security/security_dashboard/img/instance_security_dashboard_with_projects_v12_8.png b/doc/user/application_security/security_dashboard/img/instance_security_dashboard_with_projects_v12_8.png new file mode 100644 index 0000000000000000000000000000000000000000..fd0548d0b34df7ca8afa7fec376f052f29dcbf6b Binary files /dev/null and b/doc/user/application_security/security_dashboard/img/instance_security_dashboard_with_projects_v12_8.png differ diff --git a/doc/user/application_security/security_dashboard/index.md b/doc/user/application_security/security_dashboard/index.md index 38542bf811d74fa926eef46aa7c389902b07abbe..a376ac1f26bc96bb130a1e75fd737c9393a1a082 100644 --- a/doc/user/application_security/security_dashboard/index.md +++ b/doc/user/application_security/security_dashboard/index.md @@ -115,7 +115,8 @@ Read more on how to [interact with the vulnerabilities](../index.md#interacting- > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/6953) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.8. At the instance level, the Security Dashboard displays the vulnerabilities -present in all of the projects that you have added to it. +present in all of the projects that you have added to it. It includes all +of the features of the [group security dashboard](#group-security-dashboard). You can access the Instance Security Dashboard from the menu bar at the top of the page. Under **More**, select **Security**. @@ -133,7 +134,7 @@ To add projects to the dashboard: Once added, the dashboard will display the vulnerabilities found in your chosen projects. -![Instance Security Dashboard with projects](img/instance_security_dashboard_with_projects_v12_7.png) +![Instance Security Dashboard with projects](img/instance_security_dashboard_with_projects_v12_8.png) ## Keeping the dashboards up to date diff --git a/doc/user/project/clusters/add_remove_clusters.md b/doc/user/project/clusters/add_remove_clusters.md index d36c1b371f3fce0e1660b32e7aae435433fb8abe..6106c86ce3941e7a93bfdfe62d85ed3e923aabe3 100644 --- a/doc/user/project/clusters/add_remove_clusters.md +++ b/doc/user/project/clusters/add_remove_clusters.md @@ -360,6 +360,11 @@ To create and add a new Kubernetes cluster to your project, group, or instance: After about 10 minutes, your cluster will be ready to go. You can now proceed to install some [pre-defined applications](index.md#installing-applications). +NOTE: **Note:** +You will need to add your AWS external ID to the +[IAM Role in the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html#cli-configure-role-xaccount) +to manage your cluster using `kubectl`. + ## Add existing cluster If you have an existing Kubernetes cluster, you can add it to a project, group, or instance. diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index afa575241a1000dac8e0c98e310d6642cfd5b78d..e55ad8982630cf60b8b26d4ba9a91c5ffcbd030f 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -25,8 +25,6 @@ tree: - milestone: - events: - :push_event_payload - - issue_milestones: - - :milestone - resource_label_events: - label: - :priorities @@ -64,8 +62,6 @@ tree: - milestone: - events: - :push_event_payload - - merge_request_milestones: - - :milestone - resource_label_events: - label: - :priorities @@ -212,12 +208,6 @@ excluded_attributes: - :latest_merge_request_diff_id - :head_pipeline_id - :state_id - issue_milestones: - - :milestone_id - - :issue_id - merge_request_milestones: - - :milestone_id - - :merge_request_id award_emoji: - :awardable_id statuses: diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index e6a60f39bd4af36ff5cc04df748882be2e179c94..7250258061a224553637dd8b52929d3409865149 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -6,8 +6,6 @@ issues: - assignees - updated_by - milestone -- issue_milestones -- milestones - notes - resource_label_events - resource_weight_events @@ -82,8 +80,6 @@ milestone: - boards - milestone_releases - releases -- issue_milestones -- merge_request_milestones snippets: - author - project @@ -113,8 +109,6 @@ merge_requests: - assignee - updated_by - milestone -- merge_request_milestones -- milestones - notes - resource_label_events - label_links @@ -157,12 +151,6 @@ merge_requests: - deployment_merge_requests - deployments - user_mentions -issue_milestones: -- milestone -- issue -merge_request_milestones: -- milestone -- merge_request external_pull_requests: - project merge_request_diff: diff --git a/spec/models/concerns/milestoneable_spec.rb b/spec/models/concerns/milestoneable_spec.rb index 186bf2c62907784679b5b7ac6591d75437266f7c..0b19c0542eed2f42b322d05211d04567ed55ba06 100644 --- a/spec/models/concerns/milestoneable_spec.rb +++ b/spec/models/concerns/milestoneable_spec.rb @@ -35,41 +35,6 @@ describe Milestoneable do it { is_expected.to be_invalid } end - - context 'when valid and saving' do - it 'copies the value to the new milestones relationship' do - subject.save! - - expect(subject.milestones).to match_array([milestone]) - end - - context 'with old values in milestones relationship' do - let(:old_milestone) { create(:milestone, project: project) } - - before do - subject.milestone = old_milestone - subject.save! - end - - it 'replaces old values' do - expect(subject.milestones).to match_array([old_milestone]) - - subject.milestone = milestone - subject.save! - - expect(subject.milestones).to match_array([milestone]) - end - - it 'can nullify the milestone' do - expect(subject.milestones).to match_array([old_milestone]) - - subject.milestone = nil - subject.save! - - expect(subject.milestones).to match_array([]) - end - end - end end end