레일에 조명기를 사용하려고합니다. 레이크 dB : 비품 :로드 오류없이 실행 및 테이블 내 데이터를 채 웁니다하지만, 많은 내 많은 테이블이 잘못된 ID가 포함 조인레일 3 고정 장치 조인 테이블 ID가 올바르지 않습니다.
예 :
**tags.yml**
one:
id: 1
tag: pie
posts: two
two:
id: 2
tag: cake
posts: one, two
**posts.yml**
one:
id: 1
subject: subject
content: content
slug: woot
tags: cake
two:
id: 2
subject: subject2
content: content2
slug: this_is_good
tags: pie, cake
실행 마이그레이션 후
및 db:fixtures:load
내 테이블이 채워을 로 :
태그 :
ID ------ 태그
1 ...... 파이
2 ...... 케이크
posts_tags :
ROWID - post_id를은 -
1 ...... (1) ...... 974,324,064
2 ...... (2) ...... 576,189,563
3 tag_id .. .... 3 ...... 974324064
어떤 이유로 자동 생성 된 tag_id가 생성되어 내 조인 테이블에 채워집니다. 왜?
def self.up
create_table :posts do |t|
t.string :subject
t.text :content
t.timestamps
end
end
및
def self.up
create_table :tags do |t|
t.string :tag
t.timestamps
end
create_table :posts_tags, :id => false do |t|
t.integer :post_id
t.integer :tag_id
end
end
posts_tags 테이블이 이미 정의되어 posts_tags : ID => 거짓 할 일 | t | t.integer : post_id t.integer tag_id end. rowid 열이 왜 생성되는지 모르겠습니다. – Mark