@@ -269,12 +269,13 @@ public static function getModuleInfo(string $row): ?string
269
269
*/
270
270
protected function createCollection (string $ databaseName , string $ collectionName , array $ options = []): Collection
271
271
{
272
- $ collection = $ this ->dropCollection ($ databaseName , $ collectionName , $ options );
273
-
274
272
if (isset ($ options ['encryptedFields ' ])) {
275
273
throw new InvalidArgumentException ('The "encryptedFields" option is not supported by createCollection(). Time to refactor! ' );
276
274
}
277
275
276
+ $ collection = $ this ->dropCollection ($ databaseName , $ collectionName , $ options );
277
+
278
+ $ options += ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )];
278
279
$ operation = new CreateCollection ($ databaseName , $ collectionName , $ options );
279
280
$ operation ->execute ($ this ->getPrimaryServer ());
280
281
@@ -290,18 +291,19 @@ protected function createCollection(string $databaseName, string $collectionName
290
291
*/
291
292
protected function dropCollection (string $ databaseName , string $ collectionName , array $ options = []): Collection
292
293
{
293
- $ options += ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )];
294
294
$ collection = new Collection ($ this ->manager , $ databaseName , $ collectionName , $ options );
295
- $ collection ->drop ();
296
-
297
295
$ this ->collectionsToCleanup [] = [$ collection , $ options ];
298
296
297
+ $ options += ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )];
298
+ $ collection ->drop ($ options );
299
+
299
300
return $ collection ;
300
301
}
301
302
302
303
private function cleanupCollections (): void
303
304
{
304
305
foreach ($ this ->collectionsToCleanup as [$ collection , $ options ]) {
306
+ $ options += ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )];
305
307
$ collection ->drop ($ options );
306
308
}
307
309
0 commit comments