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
26d13a5b
Commit
26d13a5b
authored
Jul 26, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup internal id records for epics.
parent
555ad5b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb
...20180723130817_delete_inconsistent_internal_id_records.rb
+1
-0
spec/migrations/delete_inconsistent_internal_id_records_spec.rb
...igrations/delete_inconsistent_internal_id_records_spec.rb
+40
-1
No files found.
db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb
View file @
26d13a5b
...
...
@@ -20,6 +20,7 @@ class DeleteInconsistentInternalIdRecords < ActiveRecord::Migration
delete_internal_id_records
(
'milestones'
,
'project_id'
)
delete_internal_id_records
(
'milestones'
,
'namespace_id'
,
'group_id'
)
delete_internal_id_records
(
'ci_pipelines'
,
'project_id'
)
delete_internal_id_records
(
'epics'
,
'namespace_id'
,
'group_id'
)
end
end
...
...
spec/migrations/delete_inconsistent_internal_id_records_spec.rb
View file @
26d13a5b
...
...
@@ -79,7 +79,7 @@ describe DeleteInconsistentInternalIdRecords, :migration do
end
context
'for milestones (by group)'
do
# milestones (by group) is a little different than
all
of the other models
# milestones (by group) is a little different than
most
of the other models
let!
(
:group1
)
{
create
(
:group
)
}
let!
(
:group2
)
{
create
(
:group
)
}
let!
(
:group3
)
{
create
(
:group
)
}
...
...
@@ -116,4 +116,43 @@ describe DeleteInconsistentInternalIdRecords, :migration do
expect
{
migrate!
}.
not_to
change
{
internal_id_query
.
call
(
group3
).
size
}
end
end
context
'for milestones (by group)'
do
# epics (by group) is a little different than most of the other models
let!
(
:group1
)
{
create
(
:group
)
}
let!
(
:group2
)
{
create
(
:group
)
}
let!
(
:group3
)
{
create
(
:group
)
}
let
(
:internal_id_query
)
{
->
(
group
)
{
InternalId
.
where
(
usage:
InternalId
.
usages
[
'epics'
],
namespace:
group
)
}
}
before
do
create_list
(
:epic
,
3
,
group:
group1
)
create_list
(
:epic
,
3
,
group:
group2
)
create_list
(
:epic
,
3
,
group:
group3
)
internal_id_query
.
call
(
group1
).
first
.
tap
do
|
iid
|
iid
.
last_value
=
iid
.
last_value
-
2
# This is an inconsistent record
iid
.
save!
end
internal_id_query
.
call
(
group3
).
first
.
tap
do
|
iid
|
iid
.
last_value
=
iid
.
last_value
+
2
# This is a consistent record
iid
.
save!
end
end
it
"deletes inconsistent records"
do
expect
{
migrate!
}.
to
change
{
internal_id_query
.
call
(
group1
).
size
}.
from
(
1
).
to
(
0
)
end
it
"retains consistent records"
do
expect
{
migrate!
}.
not_to
change
{
internal_id_query
.
call
(
group2
).
size
}
end
it
"retains consistent records, especially those with a greater last_value"
do
expect
{
migrate!
}.
not_to
change
{
internal_id_query
.
call
(
group3
).
size
}
end
end
end
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