summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrate/20130218141258_convert_closed_to_state_in_issue.rb18
-rw-r--r--db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb22
-rw-r--r--db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb18
-rw-r--r--db/migrate/20130220125544_convert_merge_status_in_merge_request.rb22
-rw-r--r--db/migrate/20130419190306_allow_merges_for_forks.rb8
5 files changed, 54 insertions, 34 deletions
diff --git a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
index 9fa96203ffd..99289166e81 100644
--- a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
+++ b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
@@ -1,14 +1,18 @@
class ConvertClosedToStateInIssue < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- Issue.transaction do
- Issue.where(closed: true).update_all(state: :closed)
- Issue.where(closed: false).update_all(state: :opened)
- end
+ execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}"
+ execute "UPDATE #{table_name} SET state = 'opened' WHERE closed = #{false_value}"
end
def down
- Issue.transaction do
- Issue.where(state: :closed).update_all(closed: true)
- end
+ execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'closed'"
+ end
+
+ private
+
+ def table_name
+ Issue.table_name
end
end
diff --git a/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
index ebb7ae585e6..bd1e016d679 100644
--- a/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
+++ b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
@@ -1,16 +1,20 @@
class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- MergeRequest.transaction do
- MergeRequest.where(closed: true, merged: true).update_all(state: :merged)
- MergeRequest.where(closed: true, merged: false).update_all(state: :closed)
- MergeRequest.where(closed: false).update_all(state: :opened)
- end
+ execute "UPDATE #{table_name} SET state = 'merged' WHERE closed = #{true_value} AND merged = #{true_value}"
+ execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value} AND merged = #{false_value}"
+ execute "UPDATE #{table_name} SET state = 'opened' WHERE closed = #{false_value}"
end
def down
- MergeRequest.transaction do
- MergeRequest.where(state: :closed).update_all(closed: true)
- MergeRequest.where(state: :merged).update_all(closed: true, merged: true)
- end
+ execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'closed'"
+ execute "UPDATE #{table_name} SET closed = #{true_value}, merged = #{true_value} WHERE state = 'merged'"
+ end
+
+ private
+
+ def table_name
+ MergeRequest.table_name
end
end
diff --git a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
index 1978ea89153..d1174bc3d98 100644
--- a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
+++ b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
@@ -1,14 +1,18 @@
class ConvertClosedToStateInMilestone < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- Milestone.transaction do
- Milestone.where(closed: true).update_all(state: :closed)
- Milestone.where(closed: false).update_all(state: :active)
- end
+ execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}"
+ execute "UPDATE #{table_name} SET state = 'active' WHERE closed = #{false_value}"
end
def down
- Milestone.transaction do
- Milestone.where(state: :closed).update_all(closed: true)
- end
+ execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'cloesd'"
+ end
+
+ private
+
+ def table_name
+ Milestone.table_name
end
end
diff --git a/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb b/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb
index b310b35e373..1c758c56ffe 100644
--- a/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb
+++ b/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb
@@ -1,17 +1,19 @@
class ConvertMergeStatusInMergeRequest < ActiveRecord::Migration
def up
- MergeRequest.transaction do
- MergeRequest.where(merge_status: 1).update_all("new_merge_status = 'unchecked'")
- MergeRequest.where(merge_status: 2).update_all("new_merge_status = 'can_be_merged'")
- MergeRequest.where(merge_status: 3).update_all("new_merge_status = 'cannot_be_merged'")
- end
+ execute "UPDATE #{table_name} SET new_merge_status = 'unchecked' WHERE merge_status = 1"
+ execute "UPDATE #{table_name} SET new_merge_status = 'can_be_merged' WHERE merge_status = 2"
+ execute "UPDATE #{table_name} SET new_merge_status = 'cannot_be_merged' WHERE merge_status = 3"
end
def down
- MergeRequest.transaction do
- MergeRequest.where(new_merge_status: :unchecked).update_all("merge_status = 1")
- MergeRequest.where(new_merge_status: :can_be_merged).update_all("merge_status = 2")
- MergeRequest.where(new_merge_status: :cannot_be_merged).update_all("merge_status = 3")
- end
+ execute "UPDATE #{table_name} SET merge_status = 1 WHERE new_merge_status = 'unchecked'"
+ execute "UPDATE #{table_name} SET merge_status = 2 WHERE new_merge_status = 'can_be_merged'"
+ execute "UPDATE #{table_name} SET merge_status = 3 WHERE new_merge_status = 'cannot_be_merged'"
+ end
+
+ private
+
+ def table_name
+ MergeRequest.table_name
end
end
diff --git a/db/migrate/20130419190306_allow_merges_for_forks.rb b/db/migrate/20130419190306_allow_merges_for_forks.rb
index 56ce58a846d..56ea97e8561 100644
--- a/db/migrate/20130419190306_allow_merges_for_forks.rb
+++ b/db/migrate/20130419190306_allow_merges_for_forks.rb
@@ -1,7 +1,7 @@
class AllowMergesForForks < ActiveRecord::Migration
def self.up
add_column :merge_requests, :target_project_id, :integer, :null => true
- MergeRequest.update_all("target_project_id = project_id")
+ execute "UPDATE #{table_name} SET target_project_id = project_id"
change_column :merge_requests, :target_project_id, :integer, :null => false
rename_column :merge_requests, :project_id, :source_project_id
end
@@ -10,4 +10,10 @@ class AllowMergesForForks < ActiveRecord::Migration
remove_column :merge_requests, :target_project_id
rename_column :merge_requests, :source_project_id,:project_id
end
+
+ private
+
+ def table_name
+ MergeRequest.table_name
+ end
end