Skip to content

Instantly share code, notes, and snippets.

@solnic
Created October 10, 2010 19:34
Show Gist options
  • Select an option

  • Save solnic/619502 to your computer and use it in GitHub Desktop.

Select an option

Save solnic/619502 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'dm-core'
require "dm-migrations"
require 'dm-sqlite-adapter'
DataMapper.setup(:default, 'sqlite::memory:')
DataMapper.auto_upgrade!
class Event
include DataMapper::Resource
property :id, Serial
property :signature, Integer
belongs_to :signature, :parent_key => [:sig_id], :child_key => [:signature]
end
class Signature
include DataMapper::Resource
property :sig_id, Serial
has n, :events, :child_key => [:signature]
end
DataMapper.finalize
~ (0.000047) SELECT sqlite_version(*)
~ (0.000086) DROP TABLE IF EXISTS "events"
~ (0.000011) PRAGMA table_info("events")
~ (0.000231) CREATE TABLE "events" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "signature" INTEGER)
~ (0.000030) DROP TABLE IF EXISTS "signatures"
~ (0.000008) PRAGMA table_info("signatures")
~ (0.000087) CREATE TABLE "signatures" ("sig_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment