Prev | Current Page 146 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

The :options option will add a free-form string after the definition,
allowing you to specify things like the charset or the database engine in MySQL. Finally, if you
want the table to be created regardless of its current existence, you should use :force => true.
The column method also has a nonblock counterpart, add_column. The difference between
the two is that add_column takes the name of the table it operates on. Aside from that, they??™re the
same. Both methods take the name of the column you want to create and the data type.
The possible data types are :primary_key, :string, :text, :integer, :float, :decimal, :datetime,
:timestamp, :time, :date, :binary, and :boolean, and each corresponds to its database-specific
counterpart when the table is generated. Additionally, the add_column and column methods
take a third argument that is a hash of options that define column configuration. The available
options are :limit, :default, :null, :precision, and :scale. For more information on the
add_column and column methods and their arguments, including database-specific consideration
regarding of each of the configuration options, see TableDefinition#column in Appendix A.


Pages:
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158