How to add a new column in Laravel

A common situation during development of Laravel app could be adding a new column to already present DB table. Not Laravel way would be just add SQL script to add this new column in the table. But that's not helpful when you are developing in local and you want to perform this action in prod. In this case, we use the php artisan command to add a new column in DB table.

Let's consider, we want to add a new column paid in DB table users. To add new column paid follow the below steps -

  1. In your project root - php artisan make:migration add_paid_to_users
  2. This will create a new file database/migrations/2019_03_23_173826_add_paid_to_users.php
  3. And then you can add your new column like this
public function up()
    Schema::table('users', function($table) {
  1. In your project root - php artisan migrate

Note: You can add ->after(whichever_column) to add new column at a specific place, example $table->integer('paid')->after(whichever_column);