Hello!
I have some problems with many_to_many associations… Post should has
comment and comments should has commets…
class CreatePosts < Sequel::Migration
def up
create_table :posts do
primary_key :id
Varchar :author, :size => 128, :null => false
Text :data, :null => false
DateTime :created_at, :null => false
end
end
def down
drop_table :posts
end
end
class CreateComments < Sequel::Migration
def up
create_table :comments do
primary_key :id
DateTime :created_at, :null => false
Varchar :author, :size => 128, :null => false
Text :data, :null => false
foreign_key :post_id
end
end
def down
drop_table :comments
end
end
#i think something wrong here, but don't know right way to do this
class CreateCommentsComments < Sequel::Migration
def up
create_table :comments_comments do
primary_key :id
foreign_key :comment_id, :comments
foreign_key :parent_id, :comments
end
end
def down
drop_table :comments_comments
end
end
class Post < Sequel::Model
one_to_many :comments
end
class Comment < Sequel::Model
many_to_one :post
many_to_many :comments
end
p.s. and sorry for my english, it's not my mother language
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---