Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Created February 15, 2011 02:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knowtheory/826987 to your computer and use it in GitHub Desktop.
Save knowtheory/826987 to your computer and use it in GitHub Desktop.
Demonstrating how to do composite indexes in DataMapper
require 'dm-core'
require 'dm-migrations'
DataMapper.setup(:default, "mysql://localhost/test")
class TotallyContrivedForThisExample
include DataMapper::Resource
property :id, Serial # already part of the primary key
property :plerp, String, :key => true # Adds this to the primary key
# a composite index is created called "index_totally_contrived_for_this_example_stuff"
property :one, Integer, :index => [:stuff]
property :two, Integer, :index => [:stuff]
property :three, String, :index => [:stuff]
end
DataMapper.auto_migrate!
@jpr5
Copy link

jpr5 commented Feb 15, 2011

OH MY GOD

@shishirsharma
Copy link

You saved a lot of my time. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment