<?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: migrating to datamapper 0.9 &#8211; unique indexes</title>
	<atom:link href="http://odwks.com/2008/06/migrating-to-datamapper-09-unique-indexes/feed/" rel="self" type="application/rss+xml" />
	<link>http://odwks.com/2008/06/migrating-to-datamapper-09-unique-indexes/</link>
	<description>&#62;  old dudes who know startups</description>
	<lastBuildDate>Fri, 28 Oct 2011 23:10:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: jhancock</title>
		<link>http://odwks.com/2008/06/migrating-to-datamapper-09-unique-indexes/comment-page-1/#comment-2</link>
		<dc:creator>jhancock</dc:creator>
		<pubDate>Sat, 13 Sep 2008 09:00:41 +0000</pubDate>
		<guid isPermaLink="false">http://odwks.com/?p=14#comment-2</guid>
		<description>comment by John W Higgins:
There’s another little trick to the :unique_index concept - if you use a symbol as opposed to true then you can create multiple named indexes with multiple fields.

Extending your example slightly (but not realistically)….

&lt;code&gt;class User
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
property :email, String, :unique_index =&gt; true
property :display_name, String, :unique_index =&gt; :names
property :full_name, String, :unique_index =&gt; :names
property :address String, :unique_index =&gt; :bob
&lt;/code&gt;
Will get indexes generated along the lines of…

&lt;code&gt;Indexes:
“users_pkey” PRIMARY KEY, btree (id)
“unique_index_users_names” UNIQUE, btree (display_name, full_name)
“unique_index_users_email” UNIQUE, btree (email) “unique_index_users_bob” UNIQUE, btree (address)&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>comment by John W Higgins:<br />
There’s another little trick to the :unique_index concept &#8211; if you use a symbol as opposed to true then you can create multiple named indexes with multiple fields.</p>
<p>Extending your example slightly (but not realistically)….</p>
<p><code>class User<br />
include DataMapper::Resource<br />
property :id, Integer, :serial => true<br />
property :email, String, :unique_index => true<br />
property :display_name, String, :unique_index => :names<br />
property :full_name, String, :unique_index => :names<br />
property :address String, :unique_index => :bob<br />
</code><br />
Will get indexes generated along the lines of…</p>
<p><code>Indexes:<br />
“users_pkey” PRIMARY KEY, btree (id)<br />
“unique_index_users_names” UNIQUE, btree (display_name, full_name)<br />
“unique_index_users_email” UNIQUE, btree (email) “unique_index_users_bob” UNIQUE, btree (address)</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 0.895 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-03 13:29:30 -->

