Skip to content

Commit

Permalink
Merge pull request rails#32872 from utilum/soften_migrations_guide_ge…
Browse files Browse the repository at this point in the history
…nerator_section

Expand intro to generator in Migrations Guide
  • Loading branch information
vipulnsward committed Dec 15, 2018
2 parents adb0c7b + 8b0d29b commit f23cdd4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions guides/source/active_record_migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ generator to handle making it for you:
$ rails generate migration AddPartNumberToProducts
```

This will create an empty but appropriately named migration:
This will create an appropriately named empty migration:

```ruby
class AddPartNumberToProducts < ActiveRecord::Migration[5.0]
Expand All @@ -135,9 +135,14 @@ class AddPartNumberToProducts < ActiveRecord::Migration[5.0]
end
```

If the migration name is of the form "AddXXXToYYY" or "RemoveXXXFromYYY" and is
followed by a list of column names and types then a migration containing the
appropriate `add_column` and `remove_column` statements will be created.
This generator can do much more than append a timestamp to the file name.
Based on naming conventions and additional (optional) arguments it can
also start fleshing out the migration.

If the migration name is of the form "AddColumnToTable" or
"RemoveColumnFromTable" and is followed by a list of column names and
types then a migration containing the appropriate `add_column` and
`remove_column` statements will be created.

```bash
$ rails generate migration AddPartNumberToProducts part_number:string
Expand Down

0 comments on commit f23cdd4

Please sign in to comment.