|
52 | 52 | end |
53 | 53 |
|
54 | 54 | create_table :posts, force: true do |t| |
55 | | - t.string :title, length: 255 |
| 55 | + t.string :title, limit: 255 |
56 | 56 | t.text :body |
57 | 57 | t.integer :author_id |
58 | 58 | t.integer :parent_post_id |
|
85 | 85 | end |
86 | 86 |
|
87 | 87 | create_table :posts_tags, force: true do |t| |
88 | | - t.references :post, :tag, index: true |
| 88 | + t.references :post, index:true |
| 89 | + t.references :tag, index:true |
89 | 90 | end |
90 | 91 | add_index :posts_tags, [:post_id, :tag_id], unique: true |
91 | 92 |
|
92 | 93 | create_table :special_post_tags, force: true do |t| |
93 | | - t.references :post, :tag, index: true |
| 94 | + t.references :post, index: true |
| 95 | + t.references :tag, index: true |
94 | 96 | end |
95 | 97 | add_index :special_post_tags, [:post_id, :tag_id], unique: true |
96 | 98 |
|
97 | 99 | create_table :comments_tags, force: true do |t| |
98 | | - t.references :comment, :tag, index: true |
| 100 | + t.references :comment, index: true |
| 101 | + t.references :tag, index: true |
99 | 102 | end |
100 | 103 |
|
101 | 104 | create_table :iso_currencies, id: false, force: true do |t| |
|
324 | 327 |
|
325 | 328 | create_table :related_things, force: true do |t| |
326 | 329 | t.string :name |
327 | | - t.references :from, references: :thing |
328 | | - t.references :to, references: :thing |
| 330 | + t.references :from, foreign_key: { to_table: :things } |
| 331 | + t.references :to, foreign_key: { to_table: :things } |
329 | 332 |
|
330 | 333 | t.timestamps null: false |
331 | 334 | end |
|
0 commit comments