lib/tasks/statesman.rake in statesman-1.2.2 vs lib/tasks/statesman.rake in statesman-1.2.3

- old
+ new

@@ -13,12 +13,17 @@ done_models = 0 batch_size = 500 parent_class.find_in_batches(batch_size: batch_size) do |models| ActiveRecord::Base.transaction do - # Set all transitions' most_recent to FALSE - transition_class.where(parent_fk => models.map(&:id)). - update_all(most_recent: false) + if transition_class.columns_hash['most_recent'].null == false + # Set all transitions' most_recent to FALSE + transition_class.where(parent_fk => models.map(&:id)). + update_all(most_recent: false) + else + transition_class.where(parent_fk => models.map(&:id)). + update_all(most_recent: nil) + end # Set current transition's most_recent to TRUE ActiveRecord::Base.connection.execute %{ UPDATE #{transition_class.table_name} SET most_recent = true