我正在将 Padrino 与 DataMapper 一起使用,并且我正在尝试进行迁移以向模型添加关联。例如,我从这个开始:
class User
include DataMapper::Resource
property :id, Serial
property :name, String
end
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
end
class Comment
include DataMapper::Resource
property :id, Serial
property :name, String
end
我以以下内容结束:
class User
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :posts
end
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
belongs_to :user
has n, :comment
end
class Comment
include DataMapper::Resource
property :id, Serial
property :name, String
belongs_to :post
end
我已经有了创建三个表的迁移,但我没有添加关联。为关联创建迁移的代码是什么?