Skip to content

Commit

Permalink
Modified Migrations file
Browse files Browse the repository at this point in the history
  • Loading branch information
dyba authored and fxn committed Jul 23, 2011
1 parent 48a013d commit cf122fc
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions railties/guides/source/migrations.textile
Expand Up @@ -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. 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 h3. Creating a Migration


h4. Creating a Model h4. Creating a Model
Expand Down Expand Up @@ -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+). 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 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 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
Expand Down

0 comments on commit cf122fc

Please sign in to comment.