[Owncloud] Contacts: Cleaning up Duplicate Entries

Thomas Mayer thomas at residuum.org
Fri May 25 19:09:24 UTC 2012


Hello,

as there are several people affected by the duplicate entry bug in the
contacts app, and 4.0 is out, here is an SQL-Script to clean up the
entries. I have tested it on my own server with MySQL backend, but I am
not sure if CREATE LIKE works with PostgreSQL or SQLite:

CREATE TABLE `bu_contacts_cards` LIKE `oc_contacts_cards`;

INSERT INTO `bu_contacts_cards`
(SELECT *
	FROM (
		SELECT *
		FROM `oc_contacts_cards`
		ORDER BY id DESC
	) AS temp_table
	GROUP BY addressbookid, fullname);

TRUNCATE TABLE `oc_contacts_cards`;

INSERT INTO `oc_contacts_cards`
(SELECT * FROM `bu_contacts_cards` ORDER BY id);

DROP TABLE `bu_contacts_cards`;

Apparently this only works, if fullname has not been edited, and
fullname is unique for each address book.

Best regards,
Thomas Mayer
-- 
"We left all that stuff out. If there's an error, we have this
routine called panic, and when it is called, the machine crashes,
and you holler down the hall, 'Hey, reboot it.'" (Dennis Ritchie)
http://www.residuum.org/



More information about the Owncloud mailing list