Skip to content

apostrophecms/rename-mongodb-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rename-mongodb-database

A handy little utility from apostrophecms

Rename a mongodb database with one command:

# Talks to mongodb on localhost by default
rename-mongodb-database oldname newname

# Talk to some other mongodb installation (all MongoDB URIs work)
rename-mongodb-database oldname newname --uri=mongodb://user:pass@somewhere

# Rename many databases with a matching prefix at once
# renames oldprefix-db1 to newprefix-db1, oldprefix-db2 to newprefix-db2, etc.
# does not rename someotherprefix-db
rename-mongodb-database oldprefix newprefix --many

This command will overwrite the new database with the contents of the old, if it already exists, and drop the old database.

Installation

npm install -g @apostrophecms/rename-mongodb-database

Requirements

You must have mongosh (or mongo) mongodump and mongorestore installed. Depending on how you installed MongoDB itself, this might not be automatic. See the MongoDB documentation for more information about the MongoDB command line tools. MongoDB must be at least version 3.4.x, but keep in mind that 5.0 is the oldest release MongoDB officially supports.

About

CLI tool to rename mongodb databases with one command

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published