diff options
author | Daniel Dyba <daniel.dyba@gmail.com> | 2011-06-29 23:04:02 -0700 |
---|---|---|
committer | Daniel Dyba <daniel.dyba@gmail.com> | 2011-07-13 20:20:01 -0700 |
commit | 651cabc69a6cd661bc33824b995c2242fb65befe (patch) | |
tree | 4f96e0ddcaa238a5f53da1c3eb48e9309b793c63 /railties/guides | |
parent | 5a79ca660ad55236b7881f5e0655ae75b1b9ca37 (diff) | |
download | rails-651cabc69a6cd661bc33824b995c2242fb65befe.tar.gz rails-651cabc69a6cd661bc33824b995c2242fb65befe.tar.bz2 rails-651cabc69a6cd661bc33824b995c2242fb65befe.zip |
Modified Migrations file
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/migrations.textile | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile index dbbf8f3b51..eae337b67b 100644 --- a/railties/guides/source/migrations.textile +++ b/railties/guides/source/migrations.textile @@ -117,6 +117,33 @@ Occasionally you will make a mistake when writing a migration. If you have alrea In general editing existing migrations is not a good idea: you will be creating extra work for yourself and your co-workers and cause major headaches if the existing version of the migration has already been run on production machines. Instead you should write a new migration that performs the changes you require. Editing a freshly generated migration that has not yet been committed to source control (or more generally which has not been propagated beyond your development machine) is relatively harmless. +h4. Supported Types + +Active Record supports the following types: + +* +:primary_key+ +* +:string+ +* +:text+ +* +:integer+ +* +:float+ +* +:decimal+ +* +:datetime+ +* +:timestamp+ +* +:time+ +* +:date+ +* +:binary+ +* +:boolean+ + +These will be mapped onto an appropriate underlying database type, for example with MySQL +:string+ is mapped to +VARCHAR(255)+. You can create columns of types not supported by Active Record when using the non-sexy syntax, for example + +<ruby> +create_table :products do |t| + t.column :name, 'polygon', :null => false +end +</ruby> + +This may however hinder portability to other databases. + h3. Creating a Migration h4. Creating a Model @@ -261,18 +288,6 @@ end will append +ENGINE=BLACKHOLE+ to the SQL statement used to create the table (when using MySQL the default is +ENGINE=InnoDB+). -The types supported by Active Record are +:primary_key+, +:string+, +:text+, +:integer+, +:float+, +:decimal+, +:datetime+, +:timestamp+, +:time+, +:date+, +:binary+, +:boolean+. - -These will be mapped onto an appropriate underlying database type, for example with MySQL +:string+ is mapped to +VARCHAR(255)+. You can create columns of types not supported by Active Record when using the non-sexy syntax, for example - -<ruby> -create_table :products do |t| - t.column :name, 'polygon', :null => false -end -</ruby> - -This may however hinder portability to other databases. - h4. Changing Tables A close cousin of +create_table+ is +change_table+, used for changing existing tables. It is used in a similar fashion to +create_table+ but the object yielded to the block knows more tricks. For example |