> For the complete documentation index, see [llms.txt](https://kelby.gitbook.io/rails-beginner-s-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kelby.gitbook.io/rails-beginner-s-guide/activerecord_migration/activerecord_migration_connectionadapters/connection-adapter_table.md).

# Table

**简单划分 change\_table**

使用 create\_table 时，传递给 block 的参数 `t` 就是此类型：

```ruby
change_table :table_name do |t|
  # t.class
  # => ActiveRecord::ConnectionAdapters::Table
end
```

相关模块或方法，可以参考：TableDefinition 和 SchemaStatements#create\_table

支持的数据类型或操作有:

```ruby
change_table :table do |t|
  t.column
  t.index
  t.rename_index
  t.timestamps
  t.change
  t.change_default
  t.rename
  t.references
  t.belongs_to
  t.string
  t.text
  t.integer
  t.float
  t.decimal
  t.datetime
  t.timestamp
  t.time
  t.date
  t.binary
  t.boolean
  t.remove
  t.remove_references
  t.remove_belongs_to
  t.remove_index
  t.remove_timestamps
end
```

除上述外，还有：

```
column_exists?
index_exists?

change, change_default

remove, remove_index, remove_timestamps
remove_belongs_to & remove_references

rename, rename_index

column
index
timestamps
belongs_to & references
```

> Note: 这里有一些方法是通过元编程生成的，查文档找不到它们，可能通过 ActiveRecord::ConnectionAdapters::Table.public\_instance\_methods(false) 查看。

列举如下：

```
:column
:column_exists?
:index
:index_exists?
:rename_index
:timestamps
:change
:change_default
:remove
:remove_index
:remove_timestamps
:rename
:references
:belongs_to
:remove_references
:remove_belongs_to
:string
:text
:integer
:float
:decimal
:datetime
:timestamp
:time
:date
:binary
:boolean
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://kelby.gitbook.io/rails-beginner-s-guide/activerecord_migration/activerecord_migration_connectionadapters/connection-adapter_table.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
