db: person_id can only be updated if index is updated too.

This fixes the following error:

Mysql2::Error: Duplicate entry '0' for key
'index_profiles_on_person_id': ALTER TABLE `profiles` CHANGE `person_id`
`person_id` int(11) NOT NULL
This commit is contained in:
Andreas Schneider 2011-01-29 17:23:12 +01:00
parent e63b605b2a
commit aa6d616d69

View file

@ -20,11 +20,13 @@ class MakeFieldsNotNull < ActiveRecord::Migration
end
def self.up
remove_index(:profiles, :person_id)
non_nullable_fields.each_pair do |table, columns|
columns.each do |column|
change_column_null(table, column, false)
end
end
add_index :profiles, :person_id
end
def self.down