Skip to content

Commit 4a9e54d

Browse files
committed
Refactor database schema definitions for clarity and consistency
1 parent a3a2a7a commit 4a9e54d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

test/fixtures/active_record.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
end
5353

5454
create_table :posts, force: true do |t|
55-
t.string :title, length: 255
55+
t.string :title, limit: 255
5656
t.text :body
5757
t.integer :author_id
5858
t.integer :parent_post_id
@@ -85,17 +85,20 @@
8585
end
8686

8787
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
8990
end
9091
add_index :posts_tags, [:post_id, :tag_id], unique: true
9192

9293
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
9496
end
9597
add_index :special_post_tags, [:post_id, :tag_id], unique: true
9698

9799
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
99102
end
100103

101104
create_table :iso_currencies, id: false, force: true do |t|
@@ -324,8 +327,8 @@
324327

325328
create_table :related_things, force: true do |t|
326329
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 }
329332

330333
t.timestamps null: false
331334
end

0 commit comments

Comments
 (0)