Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

scottsuhy's avatar

What is the best way to create a column in production if an issue has occurred?

I can't say I'm new to Forge (using it for two years), but I'm still a novice...

I just realized in my production site I'm missing a column (in the user's table) that I created eight days ago, pushed to GitHub, and Deployed with Forge to AWS.

I've pushed every day since then, fine. I've even created new tables since then, fine.

The column was created on the dev server fine, and the migration file was pushed to GitHub, but it's like 'php artisan migrate' was never run on the production server.

QUESTION: What is the best way to create the column in production now that this issue has occurred?

I'm also trying to figure out what caused the issue, but when I looked back at the Forge deployment logs, they had already rolled off. It seems there are only ten saved.

0 likes
11 replies
psrz's avatar

I don't use Forge but on your migration classes you have available Schema::hasTable() and Schema::hasColumn() so you can conditionally add those columns or not depending on the situation.

scottsuhy's avatar

Here is the migration:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddFarmidToUsers extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->bigInteger('farmid')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('farmid');
        });
    }
}

when I run 'php artisan migrate:status' it shows that the migration (above) ran on the date I expected it to run. Should I still do the --force ?

scottsuhy's avatar

@MohamedTammam No, I don't see the column in the users table in production (but it is in the users table on the dev server)... a few days prior I added another column to the users table fine called 'usertype' and all was well... but something happened with 'farmid'

MohamedTammam's avatar

@scottsuhy Are you sure your ran php artisan migrate:status on production not the dev? And what's the error that you get on the production?

1 like
scottsuhy's avatar

https://imgur.com/YzccLIm here is a view of status on production. i put a yellow arrow next to it. I noticed it today when I checked in code to use the field and it failed with a 500 in production. I opened up pgadmin to look at the production users table and the column is not there. very strange.

scottsuhy's avatar

@MohamedTammam any idea the best way to create the column given it wasn't created by the migration? can I just do it via 'create column' in PgAdmin? or will this screw up what Forge is managing for me?

MohamedTammam's avatar
Level 51

@scottsuhy Not it will not.

And you can run the following command to roll it back

php artisan migrate:rollback --step=3 --force

And then run

php artisan migrate --force
1 like
scottsuhy's avatar

that worked (manually creating the column using PgAdmin). Thank you! From now on I'll be reviewing the deployment log.

1 like

Please or to participate in this conversation.