<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,12 +4,17 @@ class ConvertVersionedAssociationFromHashToObject &lt; ActiveRecord::Migration
       attributes = YAML::load(version.yaml)
       if attributes[&quot;parts&quot;]
         attributes[&quot;parts&quot;].collect! do |part_attributes|
-          part_attributes.delete(&quot;page_id&quot;)
           if existing_part = PagePart.find_by_page_id_and_name(version.versionable_id, part_attributes[&quot;name&quot;])
-              existing_part.attributes = part_attributes
-              existing_part
+            part_attributes.delete(&quot;page_id&quot;)
+            existing_part.attributes = part_attributes
+            existing_part
           else
-            PagePart.send(:instantiate, part_attributes)
+            part_attributes[&quot;page_id&quot;] = version.versionable_id
+            if version.next == nil
+              PagePart.create(part_attributes)
+            else
+              PagePart.send(:instantiate, part_attributes)
+            end
           end
         end
         version.update_attributes( :yaml =&gt; attributes.to_yaml )</diff>
      <filename>db/migrate/20090626143038_convert_versioned_association_from_hash_to_object.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0b97ec906b23f61a2ed1787d4ace265141e70d02</id>
    </parent>
  </parents>
  <author>
    <name>Jason Garber</name>
    <email>jg@jasongarber.com</email>
  </author>
  <url>http://github.com/jgarber/radiant-chronicle-extension/commit/7634e61a679fef974b1d1f1f5e214800a7393a79</url>
  <id>7634e61a679fef974b1d1f1f5e214800a7393a79</id>
  <committed-date>2009-09-21T12:55:27-07:00</committed-date>
  <authored-date>2009-09-21T12:55:27-07:00</authored-date>
  <message>Try that migration one more time.  You see, before when you created a draft and it remained a draft through the current version, it had no page parts in the main table.  Now, it does, so if it's the current version but has no page parts in the main table, create them.

Let's hope this is the last time I have to change this file!</message>
  <tree>df3ed10757e16c69baef20de363d4941a68f5e65</tree>
  <committer>
    <name>Jason Garber</name>
    <email>jg@jasongarber.com</email>
  </committer>
</commit>
