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

fredemagi's avatar

Error when deploying using Laravel Forge, DigitalOcean, and Github. Column does not exists

Hello,

I try to deploy to my server using Laravel Forge, DigItalOcean, and Github. When I deploy, it fails with the following message:

Fri May 26 20:32:29 UTC 2023

   INFO  Application is already down.  

From github.com:hjm-app/hjm
 * branch            main       -> FETCH_HEAD
Already up to date.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.  

  barryvdh/laravel-dompdf ............................................... DONE
  intervention/image .................................................... DONE
  laravel/sail .......................................................... DONE
  laravel/sanctum ....................................................... DONE
  laravel/tinker ........................................................ DONE
  laravel/ui ............................................................ DONE
  laravelcollective/html ................................................ DONE
  nesbot/carbon ......................................................... DONE
  nunomaduro/collision .................................................. DONE
  nunomaduro/termwind ................................................... DONE
  spatie/laravel-ignition ............................................... DONE
  spatie/laravel-permission ............................................. DONE
  yajra/laravel-datatables-buttons ...................................... DONE
  yajra/laravel-datatables-editor ....................................... DONE
  yajra/laravel-datatables-fractal ...................................... DONE
  yajra/laravel-datatables-html ......................................... DONE
  yajra/laravel-datatables-oracle ....................................... DONE

92 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Restarting FPM...

   INFO  Running migrations.  

  2022_11_21_092105_alter_table_users .............................. 35ms FAIL

   Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist 

  There is no column with name "user_id" on table "users".

  at vendor/doctrine/dbal/src/Schema/Exception/ColumnDoesNotExist.php:16
     12▕ final class ColumnDoesNotExist extends SchemaException
     13▕ {
     14▕     public static function new(string $columnName, string $table): self
     15▕     {
  ➜  16▕         return new self(
     17▕             sprintf('There is no column with name "%s" on table "%s".', $columnName, $table),
     18▕             self::COLUMN_DOESNT_EXIST,
     19▕         );
     20▕     }

      +11 vendor frames 
  12  database/migrations/2022_11_21_092105_alter_table_users.php:18
      Illuminate\Support\Facades\Facade::__callStatic()

      +25 vendor frames 
  38  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

I have checked that the database contains a table users with a column user_id. What do I do wrong? The migration just makes a rename of all the columns in the users' table.

Regards,

0 likes
2 replies
LaryAI's avatar
Level 58

The error message suggests that there is no column named "user_id" in the "users" table. The migration file "2022_11_21_092105_alter_table_users.php" is trying to rename all the columns in the "users" table, but it seems that the "user_id" column does not exist.

To fix this issue, you can try the following steps:

  1. Check the migration file "2022_11_21_092105_alter_table_users.php" and make sure that the "user_id" column is defined in the "up" method.

  2. Check the database schema and make sure that the "users" table has a column named "user_id".

  3. If the "user_id" column is missing, you can create it using a new migration file. For example, you can create a new migration file using the following command:

    php artisan make:migration add_user_id_to_users_table --table=users
    

    This will create a new migration file that adds a "user_id" column to the "users" table. You can then run the migration using the following command:

    php artisan migrate
    
  4. Once the "user_id" column is added to the "users" table, you can try deploying your application again.

If the issue persists, you can try rolling back the migration and then running it again. You can use the following command to roll back the migration:

php artisan migrate:rollback

This will roll back the last batch of migrations. You can then run the migration again using the following command:

php artisan migrate

Please or to participate in this conversation.