Padrino를 DataMapper와 함께 사용하고 있으며 모델에 연결을 추가하기 위해 마이그레이션을 시도하고 있습니다. 예를 들어,이로 시작 :DataMapper Association Migrations
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
나는 이미 세 개의 테이블을 만들기위한 마이그레이션을 가지고,하지만 난 협회를 추가하지 않습니다. 연결을 위해 마이그레이션을 생성하기위한 코드는 무엇입니까?
감사합니다. 먼저 마이 그 레이션을 추가해야한다고 생각했습니다. –