-
-
Save snusnu/276747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3:memory:') | |
class Quote | |
include DataMapper::Resource | |
property :id, Serial | |
has 0..n, :billings, :through => Resource | |
end | |
class Billing | |
include DataMapper::Resource | |
property :id, Serial | |
has 0..n, :quotes, :through => Resource | |
end | |
puts DataMapper::Model.descendants.inspect | |
DataMapper.auto_migrate! | |
puts DataMapper::Model.descendants.inspect | |
__END__ | |
[ree-1.8.7-2009.10] mungo:extlib snusnu$ ruby foo.rb | |
#<DataMapper::Model::DescendantSet:0x10165a778 @ancestors=nil, @descendants=[Quote, Billing]> | |
~ (0.000038) SELECT sqlite_version(*) | |
~ (0.002727) DROP TABLE IF EXISTS "quotes" | |
~ (0.002216) DROP TABLE IF EXISTS "billings" | |
~ (0.002530) DROP TABLE IF EXISTS "billing_quotes" | |
~ (0.000024) PRAGMA table_info("quotes") | |
~ (0.002243) CREATE TABLE "quotes" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT) | |
~ (0.000047) PRAGMA table_info("billings") | |
~ (0.004413) CREATE TABLE "billings" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT) | |
~ (0.000022) PRAGMA table_info("billing_quotes") | |
~ (0.002807) CREATE TABLE "billing_quotes" ("quote_id" INTEGER NOT NULL, "billing_id" INTEGER NOT NULL, PRIMARY KEY("quote_id", "billing_id")) | |
#<DataMapper::Model::DescendantSet:0x10165a778 @ancestors=nil, @descendants=[Quote, Billing, BillingQuote]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment