首页 文章

MongoDB的流明迁移模式

提问于
浏览
1

我安装了Jenssegers MongoDB,按照这个Lumen and MongoDB?的答案,它的工作原理 .

但是,我尝试使用迁移模式创建一个新集合,按照示例(https://github.com/jenssegers/laravel-mongodb#schema),它不起作用 . 我的功能:

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

我收到一条错误消息:

[MongoException]集合名称不能为空

谢谢!

1 回答

  • 0

    很晚但你可以试试

    /** 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

相关问题