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:
parent
e63b605b2a
commit
aa6d616d69
1 changed files with 2 additions and 0 deletions
|
|
@ -20,11 +20,13 @@ class MakeFieldsNotNull < ActiveRecord::Migration
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.up
|
def self.up
|
||||||
|
remove_index(:profiles, :person_id)
|
||||||
non_nullable_fields.each_pair do |table, columns|
|
non_nullable_fields.each_pair do |table, columns|
|
||||||
columns.each do |column|
|
columns.each do |column|
|
||||||
change_column_null(table, column, false)
|
change_column_null(table, column, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
add_index :profiles, :person_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue