Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created January 19, 2009 19:50
Show Gist options
  • Save ashgti/49138 to your computer and use it in GitHub Desktop.
Save ashgti/49138 to your computer and use it in GitHub Desktop.
require 'rubygems'
gem 'dm-core'
require 'dm-core'
DataMapper.setup(:default, "mysql://root:password@localhost/db_testing")
DataMapper.setup(:external, "sqlite3:///#{Dir.pwd}/db2.db")
DataMapper::Logger.new(STDOUT, :debug)
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, :debug)
class User
include DataMapper::Resource
repository :default do
property :id, Serial
property :name, String
has n, :posts
end
end
class Tag
include DataMapper::Resource
repository :default do
property :id, Serial
property :name, String
property :top_term, Boolean, :default => false
end
end
class Post
include DataMapper::Resource
property :id, Serial
repository(:external) do
property :id, Serial
property :title, String
end
belongs_to :user
# has n, :comments
end
DataMapper.auto_migrate!
DataMapper.auto_migrate! :external
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment