It might be that I have misunderstood something about using
Sequal::Migration, but this should work:
------------START-----------------------------------
class CreateBusinessprocess < Sequel::Migration
def up
create_table :bps do
primary_key :id
text :name
end
end
end
class CreateStatistic < Sequel::Migration
def up
create_table :statistics do
integer :waiting
integer :processing
primary_key :id
foreign_key :bp_id, :table => :bps
end
end
end
class Bp < Sequel::Model
one_to_many :statistics
end
class Statistic < Sequel::Model
many_to_one :bp
end
------------------END------------------------------------
But this do!!!
------------------START -----------------------------
class Bp < Sequel::Model
set_schema do
primary_key :id
text :name
end
one_to_many :statistics
end
class Statistic < Sequel::Model
set_schema do
primary_key :id
integer :waiting
foreign_key :bp_id, :table => :bps
end
many_to_one :bp
end
-------------------END------------------------------------
I have checked the DDL from both schema generations, they are
identical. Using migrations however associations will fail:
------------------START------------------------------------
/usr/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_model/record.rb:
153:in `pk': No primary key is associated with this model
(Sequel::Error)
from /usr/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_model/
record.rb:356:in `add_associated_object'
from /usr/lib/ruby/gems/1.8/gems/sequel-2.7.1/lib/sequel_model/
associations.rb:275:in `add_statistic'
from /home/morten/projects/rubyworkspace/main/Sinatra/db_helper.rb:73
from /home/morten/projects/rubyworkspace/main/Sinatra/db_helper.rb:
70:in `times'
from /home/morten/projects/rubyworkspace/main/Sinatra/db_helper.rb:70
--------------------END----------------------------------------
Hopefully there is a typo in here somewhere, but I can't find it....
Help and suggestions are very welcome!
Best regards,
Morten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---