src/Deploys/Deployer.php
protected function runClearDatabaseCollections()
    {
        $collections = db()->getCollections();
        $activated = array_keys($this->collections);

        // Carregar lista de colecoes que sobraram no banco
        $diff = Arr::where($collections, function($item) use ($activated) {
            return ! in_array($item, $activated);
        });

        // Excluir colecoes que sobraram
        foreach ($diff as $diffColl) {
            $this->note("<comment>Collection droping:</comment> {$diffColl}");
            db()->dropCollection($diffColl);
            $this->note("<comment>Collection droped:</comment> {$diffColl}");
        }

        // Carregar lista de indices
        $this->runClearDatabaseIndexs();
    }
protected function runClearDatabaseCollections()
    {
        $collections = db()->getCollections();
        $activated = array_keys($this->collections);

        // Carregar lista de colecoes que sobraram no banco
        $diff = Arr::where($collections, function($item) use ($activated) {
            return ! in_array($item, $activated);
        });

        // Excluir colecoes que sobraram
        foreach ($diff as $diffColl) {
            $this->note("<comment>Collection droping:</comment> {$diffColl}");
            db()->dropCollection($diffColl);
            $this->note("<comment>Collection droped:</comment> {$diffColl}");
        }

        // Carregar lista de indices
        $this->runClearDatabaseIndexs();
    }
protected function runClearDatabaseCollections ( ) { $ collections = db ( ) -> getCollections ( ) ; $ activated = array_keys ( $ this -> collections ) ; // Carregar lista de colecoes que sobraram no banco $ diff = Arr :: where ( $ collections , function ( $ item ) use ( $ activated ) { return ! in_array ( $ item , $ activated ) ; } ) ; // Excluir colecoes que sobraram foreach ( $ diff as $ diffColl ) { $ this -> note ( "<comment>Collection droping:</comment> {$diffColl}" ) ; db ( ) -> dropCollection ( $ diffColl ) ; $ this -> note ( "<comment>Collection droped:</comment> {$diffColl}" ) ; } // Carregar lista de indices $ this -> runClearDatabaseIndexs ( ) ; }
Run clear database collections.
Run clear database collections .