summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorAndrew8xx8 <avk@8xx8.ru>2013-02-18 18:54:30 +0400
committerAndrew8xx8 <avk@8xx8.ru>2013-02-18 18:54:30 +0400
commite5f048f44d054c0e825c880f7b58f0288cdc122f (patch)
tree983462983cba5542c0ca5b00f2e1aa28591a2322 /db/migrate
parent41e97a766b2cf5f75bfca5bb892e49eba720a330 (diff)
downloadgitlab-ce-e5f048f44d054c0e825c880f7b58f0288cdc122f.tar.gz
Migrations refactored ro support data convertion
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20130214153504_rename_closed_to_state_in_issue.rb5
-rw-r--r--db/migrate/20130214153809_change_state_type_in_issue.rb9
-rw-r--r--db/migrate/20130214154847_rename_closed_to_state_in_merge_request.rb5
-rw-r--r--db/migrate/20130214155334_change_state_type_in_merge_request.rb9
-rw-r--r--db/migrate/20130214155542_rename_closed_to_state_in_milestone.rb5
-rw-r--r--db/migrate/20130214155632_change_state_type_in_milestone.rb9
-rw-r--r--db/migrate/20130218140952_add_state_to_issue.rb5
-rw-r--r--db/migrate/20130218141038_add_state_to_merge_request.rb5
-rw-r--r--db/migrate/20130218141117_add_state_to_milestone.rb5
-rw-r--r--db/migrate/20130218141258_convert_closed_to_state_in_issue.rb19
-rw-r--r--db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb29
-rw-r--r--db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb19
-rw-r--r--db/migrate/20130218141444_remove_merged_from_merge_request.rb (renamed from db/migrate/20130218091244_remove_merged_from_merge_request.rb)0
-rw-r--r--db/migrate/20130218141507_remove_closed_from_issue.rb9
-rw-r--r--db/migrate/20130218141536_remove_closed_from_merge_request.rb9
-rw-r--r--db/migrate/20130218141554_remove_closed_from_milestone.rb9
16 files changed, 109 insertions, 42 deletions
diff --git a/db/migrate/20130214153504_rename_closed_to_state_in_issue.rb b/db/migrate/20130214153504_rename_closed_to_state_in_issue.rb
deleted file mode 100644
index 93b815686c5..00000000000
--- a/db/migrate/20130214153504_rename_closed_to_state_in_issue.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class RenameClosedToStateInIssue < ActiveRecord::Migration
- def change
- rename_column :issues, :closed, :state
- end
-end
diff --git a/db/migrate/20130214153809_change_state_type_in_issue.rb b/db/migrate/20130214153809_change_state_type_in_issue.rb
deleted file mode 100644
index 61097af0846..00000000000
--- a/db/migrate/20130214153809_change_state_type_in_issue.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ChangeStateTypeInIssue < ActiveRecord::Migration
- def up
- change_column :issues, :state, :string
- end
-
- def down
- change_column :issues, :state, :boolean
- end
-end
diff --git a/db/migrate/20130214154847_rename_closed_to_state_in_merge_request.rb b/db/migrate/20130214154847_rename_closed_to_state_in_merge_request.rb
deleted file mode 100644
index b8b7a5fdc11..00000000000
--- a/db/migrate/20130214154847_rename_closed_to_state_in_merge_request.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class RenameClosedToStateInMergeRequest < ActiveRecord::Migration
- def change
- rename_column :merge_requests, :closed, :state
- end
-end
diff --git a/db/migrate/20130214155334_change_state_type_in_merge_request.rb b/db/migrate/20130214155334_change_state_type_in_merge_request.rb
deleted file mode 100644
index 189b48f4516..00000000000
--- a/db/migrate/20130214155334_change_state_type_in_merge_request.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ChangeStateTypeInMergeRequest < ActiveRecord::Migration
- def up
- change_column :merge_requests, :state, :string
- end
-
- def down
- change_column :merge_requests, :state, :boolean
- end
-end
diff --git a/db/migrate/20130214155542_rename_closed_to_state_in_milestone.rb b/db/migrate/20130214155542_rename_closed_to_state_in_milestone.rb
deleted file mode 100644
index 39c1b7c8697..00000000000
--- a/db/migrate/20130214155542_rename_closed_to_state_in_milestone.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class RenameClosedToStateInMilestone < ActiveRecord::Migration
- def change
- rename_column :milestones, :closed, :state
- end
-end
diff --git a/db/migrate/20130214155632_change_state_type_in_milestone.rb b/db/migrate/20130214155632_change_state_type_in_milestone.rb
deleted file mode 100644
index db0365b1095..00000000000
--- a/db/migrate/20130214155632_change_state_type_in_milestone.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class ChangeStateTypeInMilestone < ActiveRecord::Migration
- def up
- change_column :milestones, :state, :string
- end
-
- def down
- change_column :milestones, :state, :boolean
- end
-end
diff --git a/db/migrate/20130218140952_add_state_to_issue.rb b/db/migrate/20130218140952_add_state_to_issue.rb
new file mode 100644
index 00000000000..062103d0e33
--- /dev/null
+++ b/db/migrate/20130218140952_add_state_to_issue.rb
@@ -0,0 +1,5 @@
+class AddStateToIssue < ActiveRecord::Migration
+ def change
+ add_column :issues, :state, :string
+ end
+end
diff --git a/db/migrate/20130218141038_add_state_to_merge_request.rb b/db/migrate/20130218141038_add_state_to_merge_request.rb
new file mode 100644
index 00000000000..ac4108ee311
--- /dev/null
+++ b/db/migrate/20130218141038_add_state_to_merge_request.rb
@@ -0,0 +1,5 @@
+class AddStateToMergeRequest < ActiveRecord::Migration
+ def change
+ add_column :merge_requests, :state, :string
+ end
+end
diff --git a/db/migrate/20130218141117_add_state_to_milestone.rb b/db/migrate/20130218141117_add_state_to_milestone.rb
new file mode 100644
index 00000000000..c84039106bd
--- /dev/null
+++ b/db/migrate/20130218141117_add_state_to_milestone.rb
@@ -0,0 +1,5 @@
+class AddStateToMilestone < ActiveRecord::Migration
+ def change
+ add_column :milestones, :state, :string
+ end
+end
diff --git a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
new file mode 100644
index 00000000000..c20fd634e82
--- /dev/null
+++ b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
@@ -0,0 +1,19 @@
+class ConvertClosedToStateInIssue < ActiveRecord::Migration
+ def up
+ Issue.transaction do
+ Issue.find_each do |issue|
+ issue.state = issue.closed? ? :closed : :opened
+ issue.save
+ end
+ end
+ end
+
+ def down
+ Issue.transaction do
+ Issue.find_each do |issue|
+ issue.closed = issue.closed?
+ issue.save
+ end
+ end
+ 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
new file mode 100644
index 00000000000..5aa5f48ce66
--- /dev/null
+++ b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
@@ -0,0 +1,29 @@
+class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration
+ def up
+ MergeRequest.transaction do
+ MergeRequest.find_each do |mr|
+ if mr.closed? && mr.merged?
+ mr.state = :merged
+ else
+ if mr.closed?
+ mr.state = :closed
+ else
+ mr.state = :opened
+ end
+ end
+
+ mr.save
+ end
+ end
+ end
+
+ def down
+ MergeRequest.transaction do
+ MergeRequest.find_each do |mr|
+ mr.closed = mr.closed? || mr.merged?
+ mr.closed = mr.merged?
+ mr.save
+ end
+ end
+ 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
new file mode 100644
index 00000000000..4490ebc35ad
--- /dev/null
+++ b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
@@ -0,0 +1,19 @@
+class ConvertClosedToStateInMilestone < ActiveRecord::Migration
+ def up
+ Milestone.transaction do
+ Milestone.find_each do |milestone|
+ milestone.state = milestone.closed? ? :closed : :active
+ milestone.save
+ end
+ end
+ end
+
+ def down
+ Milestone.transaction do
+ Milestone.find_each do |milestone|
+ milestone.closed = milestone.closed?
+ milestone.save
+ end
+ end
+ end
+end
diff --git a/db/migrate/20130218091244_remove_merged_from_merge_request.rb b/db/migrate/20130218141444_remove_merged_from_merge_request.rb
index a7bd82f5000..a7bd82f5000 100644
--- a/db/migrate/20130218091244_remove_merged_from_merge_request.rb
+++ b/db/migrate/20130218141444_remove_merged_from_merge_request.rb
diff --git a/db/migrate/20130218141507_remove_closed_from_issue.rb b/db/migrate/20130218141507_remove_closed_from_issue.rb
new file mode 100644
index 00000000000..95cc064252b
--- /dev/null
+++ b/db/migrate/20130218141507_remove_closed_from_issue.rb
@@ -0,0 +1,9 @@
+class RemoveClosedFromIssue < ActiveRecord::Migration
+ def up
+ remove_column :issues, :closed
+ end
+
+ def down
+ add_column :issues, :closed, :boolean
+ end
+end
diff --git a/db/migrate/20130218141536_remove_closed_from_merge_request.rb b/db/migrate/20130218141536_remove_closed_from_merge_request.rb
new file mode 100644
index 00000000000..371835938b2
--- /dev/null
+++ b/db/migrate/20130218141536_remove_closed_from_merge_request.rb
@@ -0,0 +1,9 @@
+class RemoveClosedFromMergeRequest < ActiveRecord::Migration
+ def up
+ remove_column :merge_requests, :closed
+ end
+
+ def down
+ add_column :merge_requests, :closed, :boolean
+ end
+end
diff --git a/db/migrate/20130218141554_remove_closed_from_milestone.rb b/db/migrate/20130218141554_remove_closed_from_milestone.rb
new file mode 100644
index 00000000000..e8dae4a19b1
--- /dev/null
+++ b/db/migrate/20130218141554_remove_closed_from_milestone.rb
@@ -0,0 +1,9 @@
+class RemoveClosedFromMilestone < ActiveRecord::Migration
+ def up
+ remove_column :milestones, :closed
+ end
+
+ def down
+ add_column :milestones, :closed, :boolean
+ end
+end