BigW Consortium Gitlab

Commit 96af55bb by Dmitriy Zaporozhets

if for migration

parent 552c6d45
...@@ -3,7 +3,13 @@ class MoveNoteableCommitToOwnField < ActiveRecord::Migration ...@@ -3,7 +3,13 @@ class MoveNoteableCommitToOwnField < ActiveRecord::Migration
add_column :notes, :commit_id, :string, null: true add_column :notes, :commit_id, :string, null: true
add_column :notes, :new_noteable_id, :integer, 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('commit_id = noteable_id')
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = CAST (noteable_id AS INTEGER)') 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 remove_column :notes, :noteable_id
rename_column :notes, :new_noteable_id, :noteable_id rename_column :notes, :new_noteable_id, :noteable_id
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment