<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Migrations with Mongo (and MongoMapper)</title>
	<atom:link href="http://terrbear.org/?feed=rss2&#038;p=249" rel="self" type="application/rss+xml" />
	<link>http://terrbear.org/?p=249</link>
	<description>ruby! rails! kids! oh my! ... and other fun from terry heath</description>
	<lastBuildDate>Tue, 31 Aug 2010 17:32:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: terry</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-965</link>
		<dc:creator>terry</dc:creator>
		<pubDate>Wed, 03 Mar 2010 13:14:39 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-965</guid>
		<description>So I think I might be in the crazy part of the population that likes migrations, almost to a fault, but I have read a lot of posts with that sentiment. 

When I read your first comment I was originally thinking of a middle_initial counter argument, but I decided that you&#039;d probably answer with a method that tries to figure it out.

I&#039;m not sure what I think of that implementation though. I&#039;ve done it a lot in the past, where the accessor defaults the value which lets the db clean itself up, but I&#039;m not sure I want the default values to live in the model. Then again, maybe that&#039;s where they&#039;re supposed to live. 

I think if you can write queries without having to worry about the defaults, then your solution is just as appropriate as a mig(mong)ration. 

Feel free to change my mind.</description>
		<content:encoded><![CDATA[<p>So I think I might be in the crazy part of the population that likes migrations, almost to a fault, but I have read a lot of posts with that sentiment. </p>
<p>When I read your first comment I was originally thinking of a middle_initial counter argument, but I decided that you&#8217;d probably answer with a method that tries to figure it out.</p>
<p>I&#8217;m not sure what I think of that implementation though. I&#8217;ve done it a lot in the past, where the accessor defaults the value which lets the db clean itself up, but I&#8217;m not sure I want the default values to live in the model. Then again, maybe that&#8217;s where they&#8217;re supposed to live. </p>
<p>I think if you can write queries without having to worry about the defaults, then your solution is just as appropriate as a mig(mong)ration. </p>
<p>Feel free to change my mind.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: terry</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-964</link>
		<dc:creator>terry</dc:creator>
		<pubDate>Wed, 03 Mar 2010 13:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-964</guid>
		<description>Not at all. If I can&#039;t defend the way of doing it, then there&#039;s not really a point to having it, am I right? :)</description>
		<content:encoded><![CDATA[<p>Not at all. If I can&#8217;t defend the way of doing it, then there&#8217;s not really a point to having it, am I right? <img src='http://terrbear.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Eley</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-960</link>
		<dc:creator>Stephen Eley</dc:creator>
		<pubDate>Wed, 03 Mar 2010 07:25:04 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-960</guid>
		<description>Oh, and hey -- for what it&#039;s worth, it really wasn&#039;t my intention to be a hater here.  I&#039;m playing Devil&#039;s Advocate to some extent, but I don&#039;t actually think this is a bad idea.  We have different approaches, but that&#039;s not a Bad Thing.  And the implementation looks decent.  (You do need tests, though.)  &gt;8-P

I can particularly see how this could be a handy helper for someone just transitioning into MongoMapper from more ActiveRecordish approaches, or even for an existing Rails project that&#039;s starting to move &lt;i&gt;some&lt;/i&gt; models into Mongo but not all at once.

So please don&#039;t read my comments above as trying to say &quot;This is stupid and you should stop.&quot;  If I meant that, that would be stupid. And I should stop.</description>
		<content:encoded><![CDATA[<p>Oh, and hey &#8212; for what it&#8217;s worth, it really wasn&#8217;t my intention to be a hater here.  I&#8217;m playing Devil&#8217;s Advocate to some extent, but I don&#8217;t actually think this is a bad idea.  We have different approaches, but that&#8217;s not a Bad Thing.  And the implementation looks decent.  (You do need tests, though.)  &gt;8-P</p>
<p>I can particularly see how this could be a handy helper for someone just transitioning into MongoMapper from more ActiveRecordish approaches, or even for an existing Rails project that&#8217;s starting to move <i>some</i> models into Mongo but not all at once.</p>
<p>So please don&#8217;t read my comments above as trying to say &#8220;This is stupid and you should stop.&#8221;  If I meant that, that would be stupid. And I should stop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Eley</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-959</link>
		<dc:creator>Stephen Eley</dc:creator>
		<pubDate>Wed, 03 Mar 2010 07:06:20 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-959</guid>
		<description>My point about defaults was just that they&#039;ll help you avoid the dreaded NoMethodError.  They&#039;re obviously no substitute for having actual data.

As it happens, I &lt;i&gt;have&lt;/i&gt; run into the name-splitting issue in the recent past, thanks to having to integrate with a braindead membership database.  I handled it by overriding the read accessors to figure it out from the Name field when the more specific ones weren&#039;t filled in.  I even tried to handle middle initials (our audience is academics, so this matters):

    # An intelligent guess at first name where none exists
    def first_name
      attributes[:first_name] &#124;&#124; name.split[0]
    end
  
    # An intelligent guess at middle initial where none exists
    def middle_name
      attributes[:middle_name] &#124;&#124; (((a = name.split($;,3)).length == 3) ? a[1] : nil)
    end
    
    # An intelligent guess at last name where none exists
    def last_name
      attributes[:last_name] &#124;&#124; name.split($;,3)[-1]
    end

This isn&#039;t perfect, but it&#039;s a decent 80% solution, and the user can fix any mistakes themselves in their profile.  Querying&#039;s not really a problem; you just do a regex query into the complete Name field, which will have all the components.


&lt;i&gt;It’s just given as part of most deployments today anyway that you’ll need to migrate your database,&lt;/i&gt;

But some of us started using MongoDB in part to get away from that.  &gt;8-&gt;</description>
		<content:encoded><![CDATA[<p>My point about defaults was just that they&#8217;ll help you avoid the dreaded NoMethodError.  They&#8217;re obviously no substitute for having actual data.</p>
<p>As it happens, I <i>have</i> run into the name-splitting issue in the recent past, thanks to having to integrate with a braindead membership database.  I handled it by overriding the read accessors to figure it out from the Name field when the more specific ones weren&#8217;t filled in.  I even tried to handle middle initials (our audience is academics, so this matters):</p>
<p>    # An intelligent guess at first name where none exists<br />
    def first_name<br />
      attributes[:first_name] || name.split[0]<br />
    end</p>
<p>    # An intelligent guess at middle initial where none exists<br />
    def middle_name<br />
      attributes[:middle_name] || (((a = name.split($;,3)).length == 3) ? a[1] : nil)<br />
    end</p>
<p>    # An intelligent guess at last name where none exists<br />
    def last_name<br />
      attributes[:last_name] || name.split($;,3)[-1]<br />
    end</p>
<p>This isn&#8217;t perfect, but it&#8217;s a decent 80% solution, and the user can fix any mistakes themselves in their profile.  Querying&#8217;s not really a problem; you just do a regex query into the complete Name field, which will have all the components.</p>
<p><i>It’s just given as part of most deployments today anyway that you’ll need to migrate your database,</i></p>
<p>But some of us started using MongoDB in part to get away from that.  &gt;8-&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: terry</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-954</link>
		<dc:creator>terry</dc:creator>
		<pubDate>Mon, 01 Mar 2010 22:34:53 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-954</guid>
		<description>I think as soon as you decide to, say, break name into first_name and last_name, default starts to fall short. You want to write a query where last_name != &#039;foo&#039;, but :default doesn&#039;t fix that (I don&#039;t think).

The only rake task is a single one, just to run mongrations. It&#039;s just given as part of most deployments today anyway that you&#039;ll need to migrate your database, so it lets developers add something in that will get run automagically - no notes, &quot;hey run this after you push the code.&quot;

I really like rollbacks when writing migrations. I&#039;ll usually re-run the same migration several times.</description>
		<content:encoded><![CDATA[<p>I think as soon as you decide to, say, break name into first_name and last_name, default starts to fall short. You want to write a query where last_name != &#8216;foo&#8217;, but :default doesn&#8217;t fix that (I don&#8217;t think).</p>
<p>The only rake task is a single one, just to run mongrations. It&#8217;s just given as part of most deployments today anyway that you&#8217;ll need to migrate your database, so it lets developers add something in that will get run automagically &#8211; no notes, &#8220;hey run this after you push the code.&#8221;</p>
<p>I really like rollbacks when writing migrations. I&#8217;ll usually re-run the same migration several times.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Eley</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-952</link>
		<dc:creator>Stephen Eley</dc:creator>
		<pubDate>Mon, 01 Mar 2010 19:33:07 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-952</guid>
		<description>&lt;i&gt;As a result, the first time I tried to visit a page with my user, I got a sweet NoMethodError, because apparently nil doesn’t implement strftime.&lt;/i&gt;

...Or your partner could have added a &lt;b&gt;:default =&gt;&lt;/b&gt; value on any new keys he created in the model, which in Does the Right Thing in MongoMapper and takes the place of &quot;nil&quot; for any existing records.

This is a neat idea, but I don&#039;t see much use for a whole new layer of process in a typical MongoMapper app deployment.  MM can handle the uncomplicated cases very elegantly with defaults and callbacks.  For the complicated cases where data does need to be transformed, you haven&#039;t really removed the overhead of having to remember to run a Rake task.  That&#039;s not hard for a typical small project, and if your development is incremental and additive, changes that warrant it shouldn&#039;t be that common.  If I had a big team or big production app farm where I&#039;d have to worry about more than a couple of installations, I&#039;d probably roll the transformation script into an initializer in the app.  That way I could be sure it was done before the code that needed it.

Rollbacks are sort of a silly idea in MongoMapper.  Again, a data transformation that breaks old code is just so rare.  They were a silly idea in ActiveRecord migrations too -- I&#039;ve never seen a production snafu where a migration rollback was part of the recovery.  So much coding time goes into them, and yet it&#039;s so much more reliable just to back up the database as part of a deployment and then restore from it if things explode.</description>
		<content:encoded><![CDATA[<p><i>As a result, the first time I tried to visit a page with my user, I got a sweet NoMethodError, because apparently nil doesn’t implement strftime.</i></p>
<p>&#8230;Or your partner could have added a <b>:default =&gt;</b> value on any new keys he created in the model, which in Does the Right Thing in MongoMapper and takes the place of &#8220;nil&#8221; for any existing records.</p>
<p>This is a neat idea, but I don&#8217;t see much use for a whole new layer of process in a typical MongoMapper app deployment.  MM can handle the uncomplicated cases very elegantly with defaults and callbacks.  For the complicated cases where data does need to be transformed, you haven&#8217;t really removed the overhead of having to remember to run a Rake task.  That&#8217;s not hard for a typical small project, and if your development is incremental and additive, changes that warrant it shouldn&#8217;t be that common.  If I had a big team or big production app farm where I&#8217;d have to worry about more than a couple of installations, I&#8217;d probably roll the transformation script into an initializer in the app.  That way I could be sure it was done before the code that needed it.</p>
<p>Rollbacks are sort of a silly idea in MongoMapper.  Again, a data transformation that breaks old code is just so rare.  They were a silly idea in ActiveRecord migrations too &#8212; I&#8217;ve never seen a production snafu where a migration rollback was part of the recovery.  So much coding time goes into them, and yet it&#8217;s so much more reliable just to back up the database as part of a deployment and then restore from it if things explode.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sohan</title>
		<link>http://terrbear.org/?p=249&#038;cpage=1#comment-951</link>
		<dc:creator>Sohan</dc:creator>
		<pubDate>Sun, 28 Feb 2010 09:03:03 +0000</pubDate>
		<guid isPermaLink="false">http://terrbear.org/?p=249#comment-951</guid>
		<description>Your post has been linked at www.DrinkRails.com!</description>
		<content:encoded><![CDATA[<p>Your post has been linked at <a href="http://www.DrinkRails.com" rel="nofollow">http://www.DrinkRails.com</a>!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->