mongodb disable write access (while db migration)
There are two similar options available, based on user permissions.


For the user which your application uses to connect to the DB (let's call it applicationConnUser), change its permissions: for example if it currently has the readWrite role, revoke that and grant the read role instead.
Set up a different user - leave applicationConUser unchanged and create a new account applicationConUserReadOnly to which you grant the read role - and reconfigure your application to connect with this account instead.


Note that your application may not react helpfully when its normal operations cannot write to the database; depending on how it is coded, it may crash out as soon as it gets a db error.