Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1df5653a
Commit
1df5653a
authored
Apr 20, 2020
by
Małgorzata Ksionek
Committed by
Stan Hu
Apr 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change migration to respect multiple rows in application settings table
Add cr remarks
parent
f9bf7cf9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
db/post_migrate/20200325162730_schedule_backfill_push_rules_id_in_projects.rb
...0325162730_schedule_backfill_push_rules_id_in_projects.rb
+4
-1
spec/migrations/schedule_backfill_push_rules_id_in_projects_spec.rb
...tions/schedule_backfill_push_rules_id_in_projects_spec.rb
+14
-0
No files found.
db/post_migrate/20200325162730_schedule_backfill_push_rules_id_in_projects.rb
View file @
1df5653a
...
...
@@ -18,7 +18,10 @@ class ScheduleBackfillPushRulesIdInProjects < ActiveRecord::Migration[6.0]
# Update one record that is connected to the instance
value_to_be_updated_to
=
ScheduleBackfillPushRulesIdInProjects
::
PushRules
.
find_by
(
is_sample:
true
)
&
.
id
execute
"UPDATE application_settings SET push_rule_id =
#{
value_to_be_updated_to
}
"
if
value_to_be_updated_to
if
value_to_be_updated_to
execute
"UPDATE application_settings SET push_rule_id =
#{
value_to_be_updated_to
}
WHERE id IN (SELECT MAX(id) FROM application_settings);"
end
ApplicationSetting
.
expire
...
...
spec/migrations/schedule_backfill_push_rules_id_in_projects_spec.rb
View file @
1df5653a
...
...
@@ -20,6 +20,20 @@ describe ScheduleBackfillPushRulesIdInProjects do
expect
(
setting
.
push_rule_id
).
to
eq
(
sample_rule
.
id
)
end
it
'adds global rule association to last application settings when there is more than one record without failing'
do
application_settings
=
table
(
:application_settings
)
setting_old
=
application_settings
.
create!
setting
=
application_settings
.
create!
sample_rule
=
push_rules
.
create!
(
is_sample:
true
)
Sidekiq
::
Testing
.
fake!
do
disable_migrations_output
{
migrate!
}
end
expect
(
setting_old
.
reload
.
push_rule_id
).
to
be_nil
expect
(
setting
.
reload
.
push_rule_id
).
to
eq
(
sample_rule
.
id
)
end
it
'schedules worker to migrate project push rules'
do
rule_1
=
push_rules
.
create!
rule_2
=
push_rules
.
create!
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment