aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorlxxxvi <lxxxvi@users.noreply.github.com>2019-04-07 11:35:45 +0200
committerlxxxvi <lxxxvi@users.noreply.github.com>2019-04-07 11:35:45 +0200
commitcdaa4baeccd6abf04cde5c341e08bb5035f6869a (patch)
tree649deb15db918d782c2a66ad175c28a5baa0e815 /guides/source
parentc9e4c848eeeb8999b778fa1ae52185ca5537fffe (diff)
downloadrails-cdaa4baeccd6abf04cde5c341e08bb5035f6869a.tar.gz
rails-cdaa4baeccd6abf04cde5c341e08bb5035f6869a.tar.bz2
rails-cdaa4baeccd6abf04cde5c341e08bb5035f6869a.zip
change `t.integer` to `t.bigint` where applicable
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/association_basics.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 10538eff0f..a60ce7fb32 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -384,7 +384,7 @@ end
The corresponding migration might look like this:
```ruby
-class CreateSuppliers < ActiveRecord::Migration[5.0]
+class CreateSuppliers < ActiveRecord::Migration[5.2]
def change
create_table :suppliers do |t|
t.string :name
@@ -392,7 +392,7 @@ class CreateSuppliers < ActiveRecord::Migration[5.0]
end
create_table :accounts do |t|
- t.integer :supplier_id
+ t.bigint :supplier_id
t.string :account_number
t.timestamps
end
@@ -402,7 +402,7 @@ class CreateSuppliers < ActiveRecord::Migration[5.0]
end
```
-NOTE: Using `t.integer :supplier_id` makes the foreign key naming obvious and explicit. In current versions of Rails, you can abstract away this implementation detail by using `t.references :supplier` instead.
+NOTE: Using `t.bigint :supplier_id` makes the foreign key naming obvious and explicit. In current versions of Rails, you can abstract away this implementation detail by using `t.references :supplier` instead.
### Choosing Between `has_many :through` and `has_and_belongs_to_many`
@@ -466,11 +466,11 @@ Similarly, you can retrieve `@product.pictures`.
If you have an instance of the `Picture` model, you can get to its parent via `@picture.imageable`. To make this work, you need to declare both a foreign key column and a type column in the model that declares the polymorphic interface:
```ruby
-class CreatePictures < ActiveRecord::Migration[5.0]
+class CreatePictures < ActiveRecord::Migration[5.2]
def change
create_table :pictures do |t|
t.string :name
- t.integer :imageable_id
+ t.bigint :imageable_id
t.string :imageable_type
t.timestamps
end
@@ -619,11 +619,11 @@ end
These need to be backed up by a migration to create the `assemblies_parts` table. This table should be created without a primary key:
```ruby
-class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[5.0]
+class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[5.2]
def change
create_table :assemblies_parts, id: false do |t|
- t.integer :assembly_id
- t.integer :part_id
+ t.bigint :assembly_id
+ t.bigint :part_id
end
add_index :assemblies_parts, :assembly_id