Fix ScheduleBackfillPushRulesIdInProjects fails if there are multiple rows in application_settings
requested to merge 214983-schedulebackfillpushrulesidinprojects-fails-if-there-are-multiple-rows-in into master
What does this MR do?
Since there is a possibility that application_settings table has more than one row, there is a need to update the migration.
Screenshots
== 20200325162730 ScheduleBackfillPushRulesIdInProjects: migrating ============
-- execute("UPDATE application_settings SET push_rule_id = 9")
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_application_settings_on_push_rule_id"
DETAIL: Key (push_rule_id)=(9) already exists.
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20200325162730_schedule_backfill_push_rules_id_in_projects.rb:21:in `up'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Caused by:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_application_settings_on_push_rule_id"
DETAIL: Key (push_rule_id)=(9) already exists.
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20200325162730_schedule_backfill_push_rules_id_in_projects.rb:21:in `up'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Caused by:
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_application_settings_on_push_rule_id"
DETAIL: Key (push_rule_id)=(9) already exists.
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20200325162730_schedule_backfill_push_rules_id_in_projects.rb:21:in `up'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #214983 (closed)