protected function registerCmsMigrator()
    {
        // Make sure that we do not use the same migrations table if CMS migrations
        // share the database with the app.
        $this->app->singleton('cms.migration-repository', function (Application $app) {

            $table = $this->getCore()->config(
                'database.migrations.table',
                $app['config']['database.migrations']
            );

            return new DatabaseMigrationRepository($app['db'], $table);
        });

        // This CMS migrator uses the exact same binding setup as the normal migrator,
        // except for this table configuration.
        $this->app->singleton('cms.migrator', function ($app) {
            return new Migrator($app['cms.migration-repository'], $app['db'], $app['files']);
        });


        // Bind the migrator contextually, so it will be set for the commands bound here.
        $this->app->when(MigrateCommand::class)
                  ->needs(Migrator::class)
                  ->give('cms.migrator');

        $this->app->when(MigrateInstallCommand::class)
                  ->needs(MigrationRepositoryInterface::class)
                  ->give('cms.migration-repository');

        $this->app->when(MigrateRefreshCommand::class)
                  ->needs(Migrator::class)
                  ->give('cms.migrator');

        $this->app->when(MigrateResetCommand::class)
                  ->needs(Migrator::class)
                  ->give('cms.migrator');

        $this->app->when(MigrateRollbackCommand::class)
                  ->needs(Migrator::class)
                  ->give('cms.migrator');

        $this->app->when(MigrateStatusCommand::class)
                  ->needs(Migrator::class)
                  ->give('cms.migrator');

        return $this;
    }