nucleos / NucleosUserBundle

👤 Lightweight user management for symfony.
https://docs.nucleos.rocks/projects/user-bundle/
MIT License
59 stars 18 forks source link

Mongodb schema create error #35

Closed jerzypinkas closed 4 years ago

jerzypinkas commented 4 years ago

With MongoDB ODM and default Installation from documentation on 'Step 7':

php bin/console doctrine:mongodb:schema:create --index

make response

The field 'safe' is not valid for an index specification. Specification: { key: { usernameCanonical: 1 }, safe: true, unique: true, background: false, ns: "DATABASE.User", name: "usernameCanonical_1" }

core23 commented 4 years ago

This must be a copy & paste error when importing the FOS code.

Can you provide a PR that removes all unnecessary fields(e.g. safe) here: https://github.com/nucleos/NucleosUserBundle/blob/master/src/Resources/config/doctrine-mapping/User.mongodb.xml https://github.com/nucleos/NucleosUserBundle/blob/master/src/Resources/config/doctrine-mapping/Group.mongodb.xml

jerzypinkas commented 4 years ago

vendor/nucleos/user-bundle/src/Resources/config/doctrine-mapping/User.mongodb.xml After comment out lines 20, 25, 30 (where is <option name="safe" value="true"/>) everything is OK, a message is: 'Updated indexes for all classes'

similar 'safe option' exists in file vendor/nucleos/user-bundle/src/Resources/config/doctrine-mapping/Group.mongodb.xml but I didn't test it

Also, I've found those issues: https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2963

https://stackoverflow.com/questions/41036442/mongodb-dump-from-3-2-restore-with-3-4-error-index-safe-null

core23 commented 4 years ago

Can you drop the safe option for mongo < 4?

jerzypinkas commented 4 years ago

What do you mean? I don't want to install another version of mongo.

core23 commented 4 years ago

Sorry for the late response.

Can you create a PR which removes these lines @jerzypinkas ? https://github.com/nucleos/NucleosUserBundle/blob/master/src/Resources/config/doctrine-mapping/User.mongodb.xml#L20 https://github.com/nucleos/NucleosUserBundle/blob/master/src/Resources/config/doctrine-mapping/User.mongodb.xml#L25 https://github.com/nucleos/NucleosUserBundle/blob/master/src/Resources/config/doctrine-mapping/User.mongodb.xml#L30 ... Same for the Group mapping

core23 commented 4 years ago

Can you checkout the latest dev-main version @jerzypinkas ?