Removing column from database in Laravel 5+

Your migration must look like this:

class RemoveCommentViewCount extends Migration
{
    public function up()
    {
        Schema::table('articles', function($table) {
            $table->dropColumn('comment_count');
            $table->dropColumn('view_count');
        });
    }

    public function down()
    {
        Schema::table('articles', function($table) {
            $table->integer('comment_count');
            $table->integer('view_count');
        });
    }
}

The dropColumn in the up method, because with new migration you want to delete this columns. If you make a rollback, you have another time the two columns

Leave a Comment