2

I installed Jenssegers MongoDB follow this Lumen and MongoDB? answer and it work.

However, I tried to create a new collection using migration schema follow the example (https://github.com/jenssegers/laravel-mongodb#schema) and it not work. My function up:

Schema::create('users', function($collection)
    {
        $collection->index('name');
        $collection->unique('email');
    });

I got an error message:

[MongoException] Collection name cannot be empty

Thank you!

Community
  • 1
  • 1
Huy Nguyen
  • 2,025
  • 3
  • 25
  • 37

1 Answers1

0

very late but you can try

/** Run the migrations.
 *
 * @return void
 */
public function up()
{        
    Schema::connection($this->connection)
    ->table('actions', function (Blueprint $collection) 
    {
        $collection->index('name');
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::connection($this->connection)
    ->table('actions', function (Blueprint $collection) 
    {
        $collection->drop();
    });
}

Src: https://github.com/jenssegers/laravel-mongodb/issues/859

Ariel Ruiz
  • 163
  • 2
  • 6