Search code examples
phplaravelmigration

Laravel migration duplicate class name in database/ and vendors/


While I'm trying to install a Laravel application, I encounter a different result on my localhost, and on the server:

By doing:

git clone -b my_branch http://my_repo.git test && cp ./saved/.env ./test && cd ./test && composer install && php artisan migrate

php artisan migrate is returning the error:

Symfony\Component\Debug\Exception\FatalErrorException : Cannot declare class CreateTelescopeEntriesTable, because the name is already in use

but only on the distant server (Ubuntu), and not on my localhost (Debian)

The two files in conflict are:

  • database/migrations/2018_11_20_120000_create_telescope_entries_table.php
  • vendor/laravel/telescope/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php

(It's confirmed, if I remove one of them the migration is running)

So, I'm wondering why the artisan migrate is loading the vendor migration, only on the server.

  • Composer version are identical (and the composer dump-autoload doesn't help)
  • php at version 7.2.10 on server against 7.2.12 on localhost
  • I see nothing strange in .env, which are really close on both environments
  • Laravel : ^5.7

Did you encounter something like this, what should I check?

For me the correct behavior is the one on my localhost.
Thanks

Edit: Okay, that was stupid, my migration table was different, with migrate:fresh I got the same problem on the two sides


Solution

  • Your migration table was different, with migrate:fresh you will got the same problem on the two sides.