(PHP) Make Laravel migration to change table

By | June 15, 2016

Create migration in console:

php artisan make:migration add_mycolumn_to_mytable

Use Schema::table() to access existing table (instead of Schema::create() for creating new tables)

public function up()
{
    Schema::table('mytable', function($table) {
        $table->text('mycolumn');
    });
}

public function down()
{
    Schema::table('mytable', function($table) {
        $table->text('mycolumn');
    });
}

Then run migrations:

php artisan migrate

Leave a Reply

Your email address will not be published. Required fields are marked *