Bug Report
Summary
I have GridFS document with #[File] attribute. It stores data in two collections xxx.files and xxx.chunks. MongoDBPurger drops only xxx.files but keeps xxx.chunks.
Current behavior
MongoDBPurger drops only xxx.files collection for GridFS documents.
Expected behavior
MongoDBPurger drops both xxx.files and xxx.chunks collections for GridFS documents.
How to reproduce
Add a document:
use Doctrine\ODM\MongoDB\Mapping\Annotations\File;
use Doctrine\ODM\MongoDB\Mapping\Annotations\Id;
#[File(bucketName: 'report')]
class Report
{
#[Id]
private string $id;
#[File\Filename]
private string $name;
public function getId(): string
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
}
Create the schema:
bin/console doctrine:mongodb:schema:create
After that you will see 2 collections in your db: report.files and report.chunks.
Run MongoDBPurger:
#[AsCommand('debug')]
class DebugCommand extends Command
{
public function __construct(private MongoDBPurger $purger)
{
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->purger->purge();
return Command::SUCCESS;
}
}
As MongoDBPurger calls $schemaManager->createCollections() you will get an error:
/var/www $ bin/console debug
In CreateCollection.php line 257:
Collection mydb.report.chunks already exists.
Bug Report
Summary
I have GridFS document with
#[File]attribute. It stores data in two collectionsxxx.filesandxxx.chunks.MongoDBPurgerdrops onlyxxx.filesbut keepsxxx.chunks.Current behavior
MongoDBPurgerdrops onlyxxx.filescollection for GridFS documents.Expected behavior
MongoDBPurgerdrops bothxxx.filesandxxx.chunkscollections for GridFS documents.How to reproduce
Add a document:
Create the schema:
After that you will see 2 collections in your db:
report.filesandreport.chunks.Run
MongoDBPurger:As
MongoDBPurgercalls$schemaManager->createCollections()you will get an error:/var/www $ bin/console debug In CreateCollection.php line 257: Collection mydb.report.chunks already exists.