From 91405d1f989010d7e5676b2707e2797b16b62ecd Mon Sep 17 00:00:00 2001 From: "Phil. Austermann" Date: Thu, 27 Dec 2012 11:03:54 +0100 Subject: [PATCH] - Fix PostgreSql Migration issue to 4.0 (fixes https://github.com/gitlabhq/gitlabhq/issues/2398) --- db/migrate/20121218164840_move_noteable_commit_to_own_field.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6f2da413..f6b97390 100644 --- a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb +++ b/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb @@ -5,7 +5,7 @@ class MoveNoteableCommitToOwnField < ActiveRecord::Migration 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 (CASE noteable_id WHEN \'\' THEN NULL ELSE noteable_id END AS INTEGER)') else Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = noteable_id') end