[PATCH conductor] Fix the regression introduced by the dc:setup rake task fix

Scott Seago sseago at redhat.com
Tue Jun 19 14:55:08 UTC 2012


On 06/19/2012 08:08 AM, Jan Provaznik wrote:
> On 06/15/2012 05:44 PM, ifarkas at redhat.com wrote:
>> From: Imre Farkas<ifarkas at redhat.com>
>>
>> ---
>>   src/db/migrate/20120520151500_change_permission_user.rb |    6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/src/db/migrate/20120520151500_change_permission_user.rb 
>> b/src/db/migrate/20120520151500_change_permission_user.rb
>> index d9432d3..f71ee33 100644
>> --- a/src/db/migrate/20120520151500_change_permission_user.rb
>> +++ b/src/db/migrate/20120520151500_change_permission_user.rb
>> @@ -19,6 +19,9 @@ class ChangePermissionUser<  ActiveRecord::Migration
>>       add_column :permissions, :entity_id, :integer
>>       add_column :derived_permissions, :entity_id, :integer
>>
>> +    Permission.reset_column_information
>> +    DerivedPermission.reset_column_information
>> +
>>       Permission.skip_callback(:save, :after, 
>> :update_derived_permissions)
>>       counter = 0
>>       total_perms = Permission.count
>> @@ -50,6 +53,9 @@ class ChangePermissionUser<  ActiveRecord::Migration
>>       add_column :permissions, :user_id, :integer
>>       add_column :derived_permissions, :user_id, :integer
>>
>> +    Permission.reset_column_information
>> +    DerivedPermission.reset_column_information
>> +
>>       Permission.skip_callback(:save, :after, 
>> :update_derived_permissions)
>>       Permission.all.each do |p|
>>         entity = Entity.find(p.entity_id)
>
> ACK
> I wasn't able to reproduce the regression now (w/o this patch 
> applied), it probably depends on content of DB when running this 
> migration, but the patch looks good and both db:migrate and dc:setup 
> pass with it.
>
> Jan
The likely failure situation is upgrading from a prior db with data in 
it (i.e. actual permissions objects), since the migration will iterate 
over existing Permissions after adding the new column -- this is why the 
original reset_column_information was placed _before_ the 
Permission.all.each block. The problem (with the original migration) was 
that we didn't reset col information _after_ removing the obsolete 
column, which caused errors with rake dc:setup. This patch restores the 
earlier reset col information call while keeping the later one in place, 
so it should, in theory, handle both cases now.

Scott




More information about the aeolus-devel mailing list