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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
771d3fc3
Commit
771d3fc3
authored
Oct 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split migration to create label priorities
parent
d009d38e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
32 deletions
+55
-32
db/migrate/20161014173530_create_label_priorities.rb
db/migrate/20161014173530_create_label_priorities.rb
+1
-31
db/migrate/20161018024215_migrate_labels_priority.rb
db/migrate/20161018024215_migrate_labels_priority.rb
+36
-0
db/migrate/20161018024550_remove_priority_from_labels.rb
db/migrate/20161018024550_remove_priority_from_labels.rb
+17
-0
db/schema.rb
db/schema.rb
+1
-1
No files found.
db/migrate/20161014173530_create_label_priorities.rb
View file @
771d3fc3
...
...
@@ -2,7 +2,7 @@ class CreateLabelPriorities < ActiveRecord::Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
true
DOWNTIME_REASON
=
'
Prioritezed labels will not work as expected until this migration is complete.
'
DOWNTIME_REASON
=
'
This migration adds foreign keys
'
disable_ddl_transaction!
...
...
@@ -15,41 +15,11 @@ class CreateLabelPriorities < ActiveRecord::Migration
t
.
timestamps
null:
false
end
execute
<<-
EOF
.
strip_heredoc
INSERT INTO label_priorities (project_id, label_id, priority, created_at, updated_at)
SELECT labels.project_id, labels.id, labels.priority, NOW(), NOW()
FROM labels
WHERE labels.project_id IS NOT NULL
AND labels.priority IS NOT NULL;
EOF
add_concurrent_index
:label_priorities
,
[
:project_id
,
:label_id
],
unique:
true
add_concurrent_index
:label_priorities
,
:priority
remove_column
:labels
,
:priority
end
def
down
add_column
:labels
,
:priority
,
:integer
if
Gitlab
::
Database
.
mysql?
execute
<<-
EOF
.
strip_heredoc
UPDATE labels
INNER JOIN label_priorities ON labels.id = label_priorities.label_id AND labels.project_id = label_priorities.project_id
SET labels.priority = label_priorities.priority;
EOF
else
execute
<<-
EOF
.
strip_heredoc
UPDATE labels
SET priority = label_priorities.priority
FROM label_priorities
WHERE labels.id = label_priorities.label_id
AND labels.project_id = label_priorities.project_id;
EOF
end
add_concurrent_index
:labels
,
:priority
drop_table
:label_priorities
end
end
db/migrate/20161018024215_migrate_labels_priority.rb
0 → 100644
View file @
771d3fc3
class
MigrateLabelsPriority
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
true
DOWNTIME_REASON
=
'Prioritized labels will not work as expected until this migration is complete.'
disable_ddl_transaction!
def
up
execute
<<-
EOF
.
strip_heredoc
INSERT INTO label_priorities (project_id, label_id, priority, created_at, updated_at)
SELECT labels.project_id, labels.id, labels.priority, NOW(), NOW()
FROM labels
WHERE labels.project_id IS NOT NULL
AND labels.priority IS NOT NULL;
EOF
end
def
down
if
Gitlab
::
Database
.
mysql?
execute
<<-
EOF
.
strip_heredoc
UPDATE labels
INNER JOIN label_priorities ON labels.id = label_priorities.label_id AND labels.project_id = label_priorities.project_id
SET labels.priority = label_priorities.priority;
EOF
else
execute
<<-
EOF
.
strip_heredoc
UPDATE labels
SET priority = label_priorities.priority
FROM label_priorities
WHERE labels.id = label_priorities.label_id
AND labels.project_id = label_priorities.project_id;
EOF
end
end
end
db/migrate/20161018024550_remove_priority_from_labels.rb
0 → 100644
View file @
771d3fc3
class
RemovePriorityFromLabels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
true
DOWNTIME_REASON
=
'This migration removes an existing column'
disable_ddl_transaction!
def
up
remove_column
:labels
,
:priority
,
:integer
,
index:
true
end
def
down
add_column
:labels
,
:priority
,
:integer
add_concurrent_index
:labels
,
:priority
end
end
db/schema.rb
View file @
771d3fc3
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2016101
7125927
)
do
ActiveRecord
::
Schema
.
define
(
version:
2016101
8024550
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
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