Hi, please help me,
I obviously love mongo db especially they can be handled by PHP, but for my current project I use both MySQL and Mongo as database, but MySQL is my main database in my database.php configuration however I use these code to connect and make collection:
Schema::connection('mongodb')->create('message', function($collection){
$collection->index('id');
$collection->string('message');
$collection->integer('from');
$collection->integer('to');
});
however when the function down in migration file I wrote this:
Schema::connection('mongodb')->dropIfExists('message');
But the collection didn't drop, what's wrong with my code?
Schema::connection('mongodb')->drop('mycollection');
Check Jenssegers\Mongodb\Schema\Blueprint for supported methods.
I know this is late, but I am running into this issue as well.
When I run migrate:fresh with my migration organised as the above, the error log says
a collection 'example.drivers' already exists
When I move Schema::connection('mongodb')->drop('drivers') into the up() function of the migration file, the collection is dropped and all works correctly. The down function is being reached, but it is almost as if the statement inside it is being ignored.
Only to add information at the comment of KaylaLamp the method If exists would be helpful if you do not have something alredy created.
Schema::connection('mongodb')->dropIfExists('collection');
Most helpful comment
I know this is late, but I am running into this issue as well.
When I run migrate:fresh with my migration organised as the above, the error log says
When I move
Schema::connection('mongodb')->drop('drivers')into the up() function of the migration file, the collection is dropped and all works correctly. The down function is being reached, but it is almost as if the statement inside it is being ignored.