Reputation: 124
I'm making a application with laravel 4; making a review of my application the database changed, and I need to make this changes. Instead of make changes in the databases directly I want to know if there is a way to alter the fields in the database through migration.
At first time I made this to add a new field in the table:
public function up()
{
Schema::table('convenios', function(Blueprint $table)
{
$table->string('anio');
});
}
But now, I have to alter some fields, for example change String to Text. My database is PostgreSQL. How could I do this?
Upvotes: 2
Views: 1503
Reputation: 87719
You can rename a column:
Schema::table('users', function($table)
{
$table->renameColumn('from', 'to');
});
Or drop it:
Schema::table('users', function($table)
{
$table->dropColumn('votes');
});
Other than that I'm afraid Laravel will still not support, so you'll have to go raw:
DB::statement(DB::raw('alter table users alter column...'));
Check the docs: http://laravel.com/docs/schema#renaming-columns
Upvotes: 4