# 控制台里迁移、回滚等命令

主要命令

```
rake db:migrate
rake db:rollback

rake db:migrate:up
rake db:migrate:down

rake db:migrate:redo
```

指定版本号的回滚

```
rake db:migrate:down VERSION=20141119130134
```

回滚最近几个迁移

```
rake db:rollback STEP=n
```

n 代表个数。注意：是最近几个，它们会被一起移除。

其它类似命令：

只执行指定版本号的迁移

```
rake db:migrate VERSION=20141119130134
```

只执行最近几次迁移

```
rake db:migrate STEP=n
```

回滚、然后重新执行最近几次迁移

```
rake db:migrate:redo STEP=n
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kelby.gitbook.io/rails-beginner-s-guide/activerecord_migration/activerecord_migration_readme/migration_rollback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
