I don't see an API for renaming a CouchDB database, or an option in Futon to do the same.
Short of replicating to another database and then deleting the original, is there a one-step way to rename a database?
Adding to what Dominic and PPPaul said...
Renaming the file is absolutely the way to go (make sure you rename it as the same user, not accidentally change the ownership to root
or something).
This is perfectly safe to do in a full running production environment, yes. One of the many advantages of an HTTP/REST API is that there are no adapters with stateful connections to the DB. Each request is a new request. So basically the first request to CouchDB after the rename is complete will be able to use the new name.
But wait, there's more!
One really cool thing is that even after the rename, the CouchDB server still has an open file-handle to the file itself (which isn't affected by renaming the inode), so until the CouchDB server is actually restarted you'll still be able to access the DB using the old name too.
Great observation by ATfPT in the comments, apparently the DB name needs to start with a lower case letter, otherwise it doesn't show up in Futon.
Another thing I remembered: to find out where the DB files are, run this: couch-config --db-dir
If you have access to the database file itself, (located in /var/lib/couchdb
depending on your installation) you can simply rename it.
To my knowledge, that will effectively "rename" the database. I would make sure the server is not running when you perform this operation, just in case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With