aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorClaudio B. <claudiob@users.noreply.github.com>2015-08-08 13:18:17 -0700
committerClaudio B. <claudiob@users.noreply.github.com>2015-08-08 13:18:17 -0700
commit175d8acf43acd8f540296e87180f7965b6011db5 (patch)
tree01180215e597ec292b4e2e05c4fa9dfa80e3c833 /guides
parent60dbcbdcde78e273d28913ba4e772b804d6048aa (diff)
parent4445e791575c95ab6b29208cb000ddf4cd2ee2de (diff)
downloadrails-175d8acf43acd8f540296e87180f7965b6011db5.tar.gz
rails-175d8acf43acd8f540296e87180f7965b6011db5.tar.bz2
rails-175d8acf43acd8f540296e87180f7965b6011db5.zip
Merge pull request #21166 from brooksreese/migration_seed_explanation
[ci skip] Give in-depth explanation of migrations vs. seeds.rb
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_migrations.md13
1 files changed, 9 insertions, 4 deletions
diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md
index 980dfe6953..4e5902fb3d 100644
--- a/guides/source/active_record_migrations.md
+++ b/guides/source/active_record_migrations.md
@@ -1004,7 +1004,10 @@ such features, the `execute` method can be used to execute arbitrary SQL.
Migrations and Seed Data
------------------------
-Some people use migrations to add data to the database:
+The main purpose of Rails' migration feature is to issue commands that modify the
+schema using a consistent process. Migrations can also be used
+to add or modify data. This is useful in an existing database that can't be destroyed
+and recreated, such as a production database.
```ruby
class AddInitialProducts < ActiveRecord::Migration
@@ -1020,9 +1023,11 @@ class AddInitialProducts < ActiveRecord::Migration
end
```
-However, Rails has a 'seeds' feature that should be used for seeding a database
-with initial data. It's a really simple feature: just fill up `db/seeds.rb`
-with some Ruby code, and run `rake db:seed`:
+To add initial data after a database is created, Rails has a built-in
+'seeds' feature that makes the process quick and easy. This is especially
+useful when reloading the database frequently in development and test environments.
+It's easy to get started with this feature: just fill up `db/seeds.rb` with some
+Ruby code, and run `rake db:seed`:
```ruby
5.times do |i|