Skip to content

active_record_migrations: some fixes #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/zh-TW/active_record_migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Rails 提供了一組 Rake 任務,用來執行特定的遷移。
$ rake db:migrate VERSION=20080906120000
```

若版本 `20080906120000` 大於目前版本,則會執行 `change`(或 `up`)方法,遷移到 `20080906120000`(包含)。若版本 `20080906120000` 小於目前版本,則會對版本小於 `20080906120000` (不包含)的遷移執行 `down` 方法。
若版本 `20080906120000` 大於目前版本,則會執行 `change`(或 `up`)方法,遷移到 `20080906120000`(包含)。若版本 `20080906120000` 小於目前版本,則會對版本小於目前版本且大於 `20080906120000` (不包含)的遷移執行 `down` 方法。

### 回滾

Expand Down Expand Up @@ -649,7 +649,7 @@ NOTE: 這與執行所有的遷移不一樣。這只會用 `schema.rb` 裡的內
$ rake db:migrate:up VERSION=20080906120000
```

會執行版本大於 `20080906120000` 的遷移裡面的 `change`、`up` 方法。若已經遷移過了,則 Active Record 不會執行。
會執行版本小於等於 `20080906120000` 的遷移裡面的 `change`、`up` 方法。若已經遷移過了,則 Active Record 不會執行。

### 在不同環境下執行遷移

Expand Down Expand Up @@ -803,7 +803,7 @@ class AddInitialProducts < ActiveRecord::Migration
end
```

但 Rails 有 “seeds” 這個功能,應該這麼用這個來給資料庫新增初始資料才對。用起來非常簡單,在 `db/seeds.rb` 寫些 Ruby,執行 `rake db:seed` 即可:
但 Rails 有 “seeds” 這個功能,應該用它來給資料庫新增初始資料才對。用起來非常簡單,在 `db/seeds.rb` 寫些 Ruby,執行 `rake db:seed` 即可:

```ruby
5.times do |i|
Expand Down