Add sql table column before or after specific other column – by migrations in Laravel 4.1

Yes. Create a new migration using php artisan migrate:make update_users_table.

Then use the table command as follows (if you’re using MySQL!):

Schema::table('users', function($table)
{
    $table->string('phone_nr')->after('id');
});

Once you’ve finished your migration, save it and run it using php artisan migrate and your table will be updated.

Documentation: https://laravel.com/docs/4.2/migrations#column-modifiers

Leave a Comment