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
4c0292a4
Commit
4c0292a4
authored
Feb 13, 2019
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove relative_position default value
Add migration to set existing child epics' positions
parent
bc39e655
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
6 deletions
+48
-6
db/schema.rb
db/schema.rb
+1
-1
ee/db/migrate/20190128104236_add_relative_position_to_epics.rb
.../migrate/20190128104236_add_relative_position_to_epics.rb
+1
-4
ee/db/migrate/20190218031401_set_default_position_for_child_epics.rb
...te/20190218031401_set_default_position_for_child_epics.rb
+45
-0
ee/spec/services/epic_links/create_service_spec.rb
ee/spec/services/epic_links/create_service_spec.rb
+1
-1
No files found.
db/schema.rb
View file @
4c0292a4
...
...
@@ -1114,7 +1114,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do
t
.
integer
"closed_by_id"
t
.
datetime
"closed_at"
t
.
integer
"parent_id"
t
.
integer
"relative_position"
,
default:
1073741823
,
null:
false
t
.
integer
"relative_position"
t
.
index
[
"assignee_id"
],
name:
"index_epics_on_assignee_id"
,
using: :btree
t
.
index
[
"author_id"
],
name:
"index_epics_on_author_id"
,
using: :btree
t
.
index
[
"closed_by_id"
],
name:
"index_epics_on_closed_by_id"
,
using: :btree
...
...
ee/db/migrate/20190128104236_add_relative_position_to_epics.rb
View file @
4c0292a4
...
...
@@ -8,11 +8,8 @@ class AddRelativePositionToEpics < ActiveRecord::Migration[5.0]
DOWNTIME
=
false
disable_ddl_transaction!
def
up
default_position
=
Gitlab
::
Database
::
MAX_INT_VALUE
/
2
add_column_with_default
(
:epics
,
:relative_position
,
:integer
,
default:
default_position
,
allow_null:
false
)
add_column
:epics
,
:relative_position
,
:integer
end
def
down
...
...
ee/db/migrate/20190218031401_set_default_position_for_child_epics.rb
0 → 100644
View file @
4c0292a4
# 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
SetDefaultPositionForChildEpics
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
current_position
=
nil
current_parent_id
=
nil
connection
.
exec_query
(
existing_child_epics_query
.
to_sql
).
rows
.
each
do
|
id
,
parent_id
|
if
parent_id
!=
current_parent_id
current_position
=
Gitlab
::
Database
::
MAX_INT_VALUE
/
2
current_parent_id
=
parent_id
else
current_position
+=
500
end
update_position
(
id
,
current_position
)
end
end
def
down
end
private
def
epics_table
@epics_table
||=
Arel
::
Table
.
new
(
:epics
)
end
def
existing_child_epics_query
epics_table
.
project
(
epics_table
[
:id
],
epics_table
[
:parent_id
])
.
where
(
epics_table
[
:parent_id
].
not_eq
(
nil
))
.
order
(
epics_table
[
:parent_id
],
epics_table
[
:id
].
desc
)
end
def
update_position
(
epic_id
,
position
)
execute
"UPDATE epics SET relative_position =
#{
position
}
WHERE id =
#{
epic_id
}
"
end
end
ee/spec/services/epic_links/create_service_spec.rb
View file @
4c0292a4
...
...
@@ -19,7 +19,7 @@ describe EpicLinks::CreateService, :postgresql do
end
it
'moves the new child epic to the top and moves the existing ones down'
do
existing_child_epic
=
create
(
:epic
,
group:
group
,
parent:
epic
)
existing_child_epic
=
create
(
:epic
,
group:
group
,
parent:
epic
,
relative_position:
1000
)
subject
...
...
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