Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-18 23:06:29 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-18 23:06:29 +0400
commit96af55bb852660486d25c72c937426f2d2ae971a (patch)
tree09ae635a09f6b75acc771313f4067ab6a86a192f /db
parent552c6d4598f6396456c569cfece98ae469bfa84c (diff)
if for migration
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20121218164840_move_noteable_commit_to_own_field.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb b/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb
index 556ac9e7898..59faabba093 100644
--- a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb
+++ b/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb
@@ -3,7 +3,13 @@ class MoveNoteableCommitToOwnField < ActiveRecord::Migration
add_column :notes, :commit_id, :string, null: true
add_column :notes, :new_noteable_id, :integer, null: true
Note.where(noteable_type: 'Commit').update_all('commit_id = noteable_id')
- Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = CAST (noteable_id AS INTEGER)')
+
+ if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
+ Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = CAST (noteable_id AS INTEGER)')
+ else
+ Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = noteable_id')
+ end
+
remove_column :notes, :noteable_id
rename_column :notes, :new_noteable_id, :noteable_id
end