# MongoServerError: Collection already exists. Options in createCollection command conflict with existing collection options

- **ID:** `database/mongodb-cannot-create-collection-options-conflict`
- **Domain:** database
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A collection with the same name already exists but with different options (e.g., different collation, validation rules, or storage engine settings) than those specified in the createCollection command.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 5.0 | active | — | — |
| MongoDB 6.0 | active | — | — |
| MongoDB 7.0 | active | — | — |
| MongoDB 8.0 | active | — | — |

## Workarounds

1. **Check the existing collection options with `db.getCollectionInfos({name: 'mycollection'})`. If the options are acceptable, use the existing collection without modification. If not, rename the old collection: `db.mycollection.renameCollection('mycollection_old')` and then create the new one with desired options: `db.createCollection('mycollection', {collation: {locale: 'en', strength: 2}, validator: {email: {$type: 'string'}}})`** (85% success)
   ```
   Check the existing collection options with `db.getCollectionInfos({name: 'mycollection'})`. If the options are acceptable, use the existing collection without modification. If not, rename the old collection: `db.mycollection.renameCollection('mycollection_old')` and then create the new one with desired options: `db.createCollection('mycollection', {collation: {locale: 'en', strength: 2}, validator: {email: {$type: 'string'}}})`
   ```
2. **Use collMod to modify compatible options: `db.runCommand({collMod: 'mycollection', validator: {email: {$type: 'string'}}, validationLevel: 'strict'})`. For collation, you must drop and recreate the collection.** (70% success)
   ```
   Use collMod to modify compatible options: `db.runCommand({collMod: 'mycollection', validator: {email: {$type: 'string'}}, validationLevel: 'strict'})`. For collation, you must drop and recreate the collection.
   ```

## Dead Ends

- **Drop the collection and recreate it with the desired options** — Dropping the collection will delete all data permanently; this is irreversible unless you have a backup (30% fail)
- **Ignore the error and use the collection as-is** — If the existing collection has different options (e.g., missing a required validator), your application may behave incorrectly or fail to enforce data integrity (60% fail)
- **Use the collMod command to change options on the existing collection** — collMod can only modify certain options like validation rules and indexes, but cannot change fundamental options like collation or storage engine (50% fail)
