In the bookwyrm/management/commands
directory there are some commands to manipulate the instance’s database. Some of them are documented here.
Quite often an instance will end up with duplicate books and authors or editions that appear as separate books when they are actually just different editions of the same work. This can happen because of importing editions that don’t have shared identifiers or from user mistakes. There also was a bug prior to version 0.7.5 which created a large number of duplicate books, editions, and authors. Sadly there’s no user interface to correct this for the time being, but in cases where the books are important for your instance you can use these management commands to fix some of the problems if you are using at least version 0.6.2.
Please take extra care when using these commands because if you make a mistake there’s no way to undo it.
If an edition of a book appears twice in the database and you are sure they are actually both referring to same edition, you can combine them into one with a command like this:
./bw-dev runweb python manage.py merge_editions --canonical=27 --other=38
This will copy any missing information from edition 38 (the “other” edition) over to edition 27 (the “canonical” edition) and then delete the other edition. If any field of information is in both editions then the data from the canonical edition will be kept. If the other edition is in any lists or has any comments or reviews etc then these will all be updated to point to the canonical edition instead.
You can find the numbers to use in the command by visiting the page for a book and looking at the number in the URL.
You can identify potential duplicate authors with show_duplicate_authors
:
./bw-dev runweb python manage.py show_duplicate_authors
This will list all your potential duplicate author records, based purely on their name, showing their birth and death dates if available, the count of books for each author, and a link to their page on your instance. Note that you must check that these are actually duplicates before merging them as they may be different authors with the same name.
Once confirmed, if an author is duplicated you can combine the two authors into one with a command like this:
./bw-dev runweb python manage.py merge_authors --canonical=7 --other=46
As for the editions, any extra information from the other author will be copied over to the canonical author and then the other author will be deleted. Any books written by the other author will be changed to be written by the canonical author. You can find the numbers to use in the command by visiting the page for an author and looking at the number in the URL.