mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update Migration number to ensure consistency on the documentation [ci skip]
Updated Migration number to 6.0 as there were cases where it did show 5.0 and 5.2 which may lead to confusion on a newcomer reader.
This commit is contained in:
parent
f78fb42b51
commit
12719f9d6a
2 changed files with 15 additions and 15 deletions
|
@ -366,7 +366,7 @@ database that Active Record supports using `rake`. Here's a migration that
|
||||||
creates a table:
|
creates a table:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreatePublications < ActiveRecord::Migration[5.0]
|
class CreatePublications < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :publications do |t|
|
create_table :publications do |t|
|
||||||
t.string :title
|
t.string :title
|
||||||
|
|
|
@ -101,7 +101,7 @@ NOTE: `belongs_to` associations _must_ use the singular term. If you used the pl
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateBooks < ActiveRecord::Migration[5.0]
|
class CreateBooks < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :authors do |t|
|
create_table :authors do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -132,7 +132,7 @@ end
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateSuppliers < ActiveRecord::Migration[5.0]
|
class CreateSuppliers < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :suppliers do |t|
|
create_table :suppliers do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -176,7 +176,7 @@ NOTE: The name of the other model is pluralized when declaring a `has_many` asso
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateAuthors < ActiveRecord::Migration[5.0]
|
class CreateAuthors < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :authors do |t|
|
create_table :authors do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -218,7 +218,7 @@ end
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateAppointments < ActiveRecord::Migration[5.0]
|
class CreateAppointments < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :physicians do |t|
|
create_table :physicians do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -304,7 +304,7 @@ end
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateAccountHistories < ActiveRecord::Migration[5.0]
|
class CreateAccountHistories < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :suppliers do |t|
|
create_table :suppliers do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -345,7 +345,7 @@ end
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateAssembliesAndParts < ActiveRecord::Migration[5.0]
|
class CreateAssembliesAndParts < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :assemblies do |t|
|
create_table :assemblies do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -384,7 +384,7 @@ end
|
||||||
The corresponding migration might look like this:
|
The corresponding migration might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateSuppliers < ActiveRecord::Migration[5.2]
|
class CreateSuppliers < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :suppliers do |t|
|
create_table :suppliers do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -466,7 +466,7 @@ 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:
|
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
|
```ruby
|
||||||
class CreatePictures < ActiveRecord::Migration[5.2]
|
class CreatePictures < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :pictures do |t|
|
create_table :pictures do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -483,7 +483,7 @@ end
|
||||||
This migration can be simplified by using the `t.references` form:
|
This migration can be simplified by using the `t.references` form:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreatePictures < ActiveRecord::Migration[5.0]
|
class CreatePictures < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :pictures do |t|
|
create_table :pictures do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
|
@ -514,7 +514,7 @@ With this setup, you can retrieve `@employee.subordinates` and `@employee.manage
|
||||||
In your migrations/schema, you will add a references column to the model itself.
|
In your migrations/schema, you will add a references column to the model itself.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateEmployees < ActiveRecord::Migration[5.0]
|
class CreateEmployees < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :employees do |t|
|
create_table :employees do |t|
|
||||||
t.references :manager
|
t.references :manager
|
||||||
|
@ -575,7 +575,7 @@ end
|
||||||
This declaration needs to be backed up by a corresponding foreign key column in the books table. For a brand new table, the migration might look something like this:
|
This declaration needs to be backed up by a corresponding foreign key column in the books table. For a brand new table, the migration might look something like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateBooks < ActiveRecord::Migration[5.0]
|
class CreateBooks < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :books do |t|
|
create_table :books do |t|
|
||||||
t.datetime :published_at
|
t.datetime :published_at
|
||||||
|
@ -589,7 +589,7 @@ end
|
||||||
Whereas for an existing table, it might look like this:
|
Whereas for an existing table, it might look like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class AddAuthorToBooks < ActiveRecord::Migration[5.0]
|
class AddAuthorToBooks < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
add_reference :books, :author
|
add_reference :books, :author
|
||||||
end
|
end
|
||||||
|
@ -619,7 +619,7 @@ 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:
|
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
|
```ruby
|
||||||
class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[5.2]
|
class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_table :assemblies_parts, id: false do |t|
|
create_table :assemblies_parts, id: false do |t|
|
||||||
t.bigint :assembly_id
|
t.bigint :assembly_id
|
||||||
|
@ -637,7 +637,7 @@ We pass `id: false` to `create_table` because that table does not represent a mo
|
||||||
You can also use the method `create_join_table`
|
You can also use the method `create_join_table`
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[5.0]
|
class CreateAssembliesPartsJoinTable < ActiveRecord::Migration[6.0]
|
||||||
def change
|
def change
|
||||||
create_join_table :assemblies, :parts do |t|
|
create_join_table :assemblies, :parts do |t|
|
||||||
t.index :assembly_id
|
t.index :assembly_id
|
||||||
|
|
Loading…
Reference in a new issue