Skip to content

Commit

Permalink
Document changing columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 23, 2015
1 parent 38f405d commit 2834301
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Introduction](#introduction)
- [Creating & Dropping Tables](#creating-and-dropping-tables)
- [Adding Columns](#adding-columns)
- [Changing Columns](#changing-columns)
- [Renaming Columns](#renaming-columns)
- [Dropping Columns](#dropping-columns)
- [Checking Existence](#checking-existence)
Expand Down Expand Up @@ -68,7 +69,7 @@ Command | Description
`$table->date('created_at');` | DATE equivalent to the table
`$table->dateTime('created_at');` | DATETIME equivalent to the table
`$table->decimal('amount', 5, 2);` | DECIMAL equivalent with a precision and scale
`$table->double('column', 15, 8);` | DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point
`$table->double('column', 15, 8);` | DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point
`$table->enum('choices', array('foo', 'bar'));` | ENUM equivalent to the table
`$table->float('amount');` | FLOAT equivalent to the table
`$table->increments('id');` | Incrementing ID to the table (primary key).
Expand Down Expand Up @@ -98,6 +99,23 @@ If you are using the MySQL database, you may use the `after` method to specify t

$table->string('name')->after('email');

<a name="changing-columns"></a>
## Changing Columns

Sometimes you may need to modify an existing column. For example, you may wish to increase the size of a string column. The `change` method makes it easy! For example, let's increase the size of the `name` column from 25 to 50:

Schema::table('users', function($table)
{
$table->string('name', 50)->change();
});

We could also modify a column to be nullable:

Schema::table('users', function($table)
{
$table->string('name', 50)->nullable()->change();
});

<a name="renaming-columns"></a>
## Renaming Columns

Expand Down

0 comments on commit 2834301

Please sign in to comment.