<?php

use Illuminate\Database\Migrations\Migration;

class RenameClientTable extends Migration
{
    /**
     * The raw MongoDB interface.
     * @var MongoDB
     */
    protected $mongodb;

    public function __construct()
    {
        $this->mongodb = app('db')->getMongoDB();
    }

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // The 'jenssegers/laravel-mongodb' package doesn't support Schema::rename so...
        $this->mongodb->execute('db.api_keys.renameCollection("clients");');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $this->mongodb->execute('db.clients.renameCollection("api_keys");');
    }
}

<?php

use Illuminate\Database\Migrations\Migration;

class RenameClientTable extends Migration
{
    /**
     * The raw MongoDB interface.
     * @var MongoDB
     */
    protected $mongodb;

    public function __construct()
    {
        $this->mongodb = app('db')->getMongoDB();
    }

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // The 'jenssegers/laravel-mongodb' package doesn't support Schema::rename so...
        $this->mongodb->execute('db.api_keys.renameCollection("clients", true);');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $this->mongodb->execute('db.clients.renameCollection("api_keys", true);');
    }
}

Update migration to overwrite existing destination table.
Update migration to overwrite existing destination table.

I think migrations were failing because a "lookup" would end up creating
the destination table in the QA/Thor database, and then trying to use
the `renameCollection` method would silently fail because the table
already existed.

See:
https://docs.mongodb.org/manual/reference/method/db.collection.renameCollection/
