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
9629bb96
Commit
9629bb96
authored
Oct 03, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add column type to labels and do the batch update in the same migration
parent
7e11ca86
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
18 deletions
+6
-18
db/migrate/20160919144305_add_type_to_labels.rb
db/migrate/20160919144305_add_type_to_labels.rb
+6
-1
db/migrate/20160920191518_set_project_label_type_on_labels.rb
...igrate/20160920191518_set_project_label_type_on_labels.rb
+0
-17
No files found.
db/migrate/20160919144305_add_type_to_labels.rb
View file @
9629bb96
class
AddTypeToLabels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
DOWNTIME
=
true
DOWNTIME_REASON
=
'Labels will not work as expected until this migration is complete.'
def
change
add_column
:labels
,
:type
,
:string
update_column_in_batches
(
:labels
,
:type
,
'ProjectLabel'
)
do
|
table
,
query
|
query
.
where
(
table
[
:project_id
].
not_eq
(
nil
))
end
end
end
db/migrate/20160920191518_set_project_label_type_on_labels.rb
deleted
100644 → 0
View file @
7e11ca86
class
SetProjectLabelTypeOnLabels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
update_column_in_batches
(
:labels
,
:type
,
'ProjectLabel'
)
do
|
table
,
query
|
query
.
where
(
table
[
:project_id
].
not_eq
(
nil
))
end
end
def
down
update_column_in_batches
(
:labels
,
:type
,
nil
)
do
|
table
,
query
|
query
.
where
(
table
[
:project_id
].
not_eq
(
nil
))
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