Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
0f8dbc32381f
Commit
60fdc04d
authored
Feb 27, 2013
by
Dmitriy Zaporozhets
Browse files
Merge pull request #3098 from Undev/important-migrations-fix
IMPORTANT! Data converting in migrations was wrong. Fixed
parents
872ec726a7d9
260cf7d9a0ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
View file @
0f8dbc32
class
ConvertClosedToStateInIssue
<
ActiveRecord
::
Migration
def
up
Issue
.
transaction
do
Issue
.
where
(
closed:
true
).
update_all
(
"
state
= '
closed
'"
)
Issue
.
where
(
closed:
false
).
update_all
(
"
state
= '
opened
'"
)
Issue
.
where
(
closed:
true
).
update_all
(
state
: :
closed
)
Issue
.
where
(
closed:
false
).
update_all
(
state
: :
opened
)
end
end
def
down
Issue
.
transaction
do
Issue
.
where
(
state: :closed
).
update_all
(
"
closed
= 1"
)
Issue
.
where
(
state: :closed
).
update_all
(
closed
:
true
)
end
end
end
db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
View file @
0f8dbc32
class
ConvertClosedToStateInMergeRequest
<
ActiveRecord
::
Migration
def
up
MergeRequest
.
transaction
do
MergeRequest
.
where
(
closed:
true
,
merged:
true
).
update_all
(
"
state
= '
merged
'"
)
MergeRequest
.
where
(
closed:
true
,
merged:
tru
e
).
update_all
(
"
state
= '
closed
'"
)
MergeRequest
.
where
(
closed:
false
).
update_all
(
"
state
= '
opened
'"
)
MergeRequest
.
where
(
closed:
true
,
merged:
true
).
update_all
(
state
: :
merged
)
MergeRequest
.
where
(
closed:
true
,
merged:
fals
e
).
update_all
(
state
: :
closed
)
MergeRequest
.
where
(
closed:
false
).
update_all
(
state
: :
opened
)
end
end
...
...
db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
View file @
0f8dbc32
class
ConvertClosedToStateInMilestone
<
ActiveRecord
::
Migration
def
up
Milestone
.
transaction
do
Milestone
.
where
(
closed:
fals
e
).
update_all
(
"
state
= 'opened'"
)
Milestone
.
where
(
closed:
false
).
update_all
(
"
state
= '
active
'"
)
Milestone
.
where
(
closed:
tru
e
).
update_all
(
state
: :closed
)
Milestone
.
where
(
closed:
false
).
update_all
(
state
: :
active
)
end
end
def
down
Milestone
.
transaction
do
Milestone
.
where
(
state: :closed
).
update_all
(
"
closed
= 1"
)
Milestone
.
where
(
state: :closed
).
update_all
(
closed
:
true
)
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