Commit 96af55bb852660486d25c72c937426f2d2ae971a
1 parent
552c6d45
Exists in
master
and in
4 other branches
if for migration
Showing
1 changed file
with
7 additions
and
1 deletions
Show diff stats
db/migrate/20121218164840_move_noteable_commit_to_own_field.rb
| @@ -3,7 +3,13 @@ class MoveNoteableCommitToOwnField < ActiveRecord::Migration | @@ -3,7 +3,13 @@ class MoveNoteableCommitToOwnField < ActiveRecord::Migration | ||
| 3 | add_column :notes, :commit_id, :string, null: true | 3 | add_column :notes, :commit_id, :string, null: true |
| 4 | add_column :notes, :new_noteable_id, :integer, null: true | 4 | add_column :notes, :new_noteable_id, :integer, null: true |
| 5 | Note.where(noteable_type: 'Commit').update_all('commit_id = noteable_id') | 5 | Note.where(noteable_type: 'Commit').update_all('commit_id = noteable_id') |
| 6 | - Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = CAST (noteable_id AS INTEGER)') | 6 | + |
| 7 | + if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' | ||
| 8 | + Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = CAST (noteable_id AS INTEGER)') | ||
| 9 | + else | ||
| 10 | + Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = noteable_id') | ||
| 11 | + end | ||
| 12 | + | ||
| 7 | remove_column :notes, :noteable_id | 13 | remove_column :notes, :noteable_id |
| 8 | rename_column :notes, :new_noteable_id, :noteable_id | 14 | rename_column :notes, :new_noteable_id, :noteable_id |
| 9 | end | 15 | end |