Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection Already Exists Runtime Exception #790

Closed
wayne5w opened this issue Mar 22, 2016 · 3 comments
Closed

Collection Already Exists Runtime Exception #790

wayne5w opened this issue Mar 22, 2016 · 3 comments

Comments

@wayne5w
Copy link

wayne5w commented Mar 22, 2016

I've got some simple schema create code that runs fine on the old 2.x driver. I recently moved to php 7 and the 3.x driver and now I am getting a Collection Already Exists runtime exception (below). The collection does not exist. Did something change/break?

Here is the code

       Schema::connection('mongodb')->create('virtual_version', function($collection) {
                $collection->index('id');
                $collection->index('client_id');
                ;
            });

[2016-03-22 02:15:14] local.ERROR: MongoDB\Driver\Exception\RuntimeException: collection already exists in /Users/waynewilliams/Code/testQuality/vendor/mongodb/mongodb/src/Operation/CreateCollection.php:134
Stack trace:
#0 /Users/waynewilliams/Code/testQuality/vendor/mongodb/mongodb/src/Operation/CreateCollection.php(134): MongoDB\Driver\Server->executeCommand('local', Object(MongoDB\Driver\Command))
#1 /Users/waynewilliams/Code/testQuality/vendor/mongodb/mongodb/src/Database.php(180): MongoDB\Operation\CreateCollection->execute(Object(MongoDB\Driver\Server))
#2 /Users/waynewilliams/Code/testQuality/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Blueprint.php(191): MongoDB\Database->createCollection('virtual_version')
#3 /Users/waynewilliams/Code/testQuality/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(111): Jenssegers\Mongodb\Schema\Blueprint->create()
#4 /Users/waynewilliams/Code/testQuality/database/migrations/2016_03_22_021511_create_Virtual_table.php(33): Jenssegers\Mongodb\Schema\Builder->create('virtual_version', Object(Closure))
#5 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(135): CreateVirtualTable->up()
#6 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(112): Illuminate\Database\Migrations\Migrator->runUp('2016_03_22_0215...', 1, false)
#7 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(85): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#8 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(74): Illuminate\Database\Migrations\Migrator->run('/Users/waynewil...', false)
#9 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#10 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#11 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Console/Command.php(150): Illuminate\Container\Container->call(Array)
#12 /Users/waynewilliams/Code/testQuality/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /Users/waynewilliams/Code/testQuality/vendor/symfony/console/Application.php(841): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /Users/waynewilliams/Code/testQuality/vendor/symfony/console/Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /Users/waynewilliams/Code/testQuality/vendor/symfony/console/Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /Users/waynewilliams/Code/testQuality/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /Users/waynewilliams/Code/testQuality/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 {main}

@wayne5w
Copy link
Author

wayne5w commented Mar 22, 2016

Actually this is not the problem, need to investigate more. Something has changed, not sure what.

@wayne5w wayne5w closed this as completed Mar 22, 2016
@diegogandrade
Copy link

@wayne5w i got the same issue with Laravel 5.5.* and mongo 3.4.*

add this code on your "down" method:

Schema::connection("mongodb")->dropIfExists('establishments');

@navneetccna
Copy link

found any solution for this problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants