On 5/3/24 03:59, Odhiambo Washington wrote:
On Thu, May 2, 2024 at 8:11 PM Mark Sapiro <mark@msapiro.net> wrote:
On 5/2/24 03:42, Odhiambo Washington wrote:
I have deleted a list (list@nog.ke) - list_id = list.nog.ke. I can see from Django Admin UI that the archives are still intact. I created a new list (list@lists.nog.ke) - list_id = list.lists.nog.ke Is there a way to move the archives from the old list to the new list?
Change the
name
andlist_id
in the list's entry in thehyperkitty_mailinglist
table in the database. If there is already an entry there for the new list, delete itmysql> select id, name, list_id from hyperkitty_mailinglist; +----+----------------------------+----------------------------+ | id | name | list_id | +----+----------------------------+----------------------------+ | 1 | skunkworks@lists.my.co.ke | skunkworks.lists.my.co.ke | | 2 | list@nog.ke | list.nog.ke | | 3 | eanog@lists.my.co.ke | eanog.lists.my.co.ke | | 4 | isoc@lists.my.co.ke | isoc.lists.my.co.ke | | 5 | kazi@lists.my.co.ke | kazi.lists.my.co.ke | | 6 | kenog@lists.my.co.ke | kenog.lists.my.co.ke | | 7 | mechanics@lists.my.co.ke | mechanics.lists.my.co.ke | | 8 | science@lists.my.co.ke | science.lists.my.co.ke | | 9 | security@lists.my.co.ke | security.lists.my.co.ke | | 10 | vmware_tech@lists.my.co.ke | vmware_tech.lists.my.co.ke | | 11 | water@lists.my.co.ke | water.lists.my.co.ke | | 12 | wordpress@lists.my.co.ke | wordpress.lists.my.co.ke | | 13 | list@lists.nog.ke | list.lists.nog.ke | +----+----------------------------+----------------------------+ 13 rows in set (0.00 sec) mysql> delete from hyperkitty_mailinglist where id = 13; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`mailmansuite`.`hyperkitty_mailinglist_owners`, CONSTRAINT `hyperkitty_mailingli_mailinglist_id_a47e04ec_fk_hyperkitt` FOREIGN KEY (`mailinglist_id`) REFERENCES `hyperkitty_mailinglist` (`id`))
Is there an easier way? I need to delete id=13 then rename id=2
There are several tables that reference the hyperkitty_mailinglist table by id. These are hyperkitty_email, hyperkitty_mailinglist_owners, hyperkitty_mailinglist_moderators and hyperkitty_thread. Ideally, you wouldn't have created the list@lists.nog.ke before updating the hyperkitty_mailinglist entry, but now, do the following:
update hyperkitty_email set mailinglist_id = 2 where mailinglist_id = 13;
update hyperkitty_mailinglist_owners set mailinglist_id = 2 where
mailinglist_id = 13;
update hyperkitty_mailinglist_moderators set mailinglist_id = 2 where
mailinglist_id = 13;
update hyperkitty_thread set mailinglist_id = 2 where mailinglist_id = 13;
delete from hyperkitty_mailinglist where id = 13;
update hyperkitty_mailinglist set name = 'list@lists.nog.ke', list_id =
'list.lists.nog.ke' where id = 2;
If there have been no posts to the list@lists.nog.ke list the updates of hyperkitty_email and hyperkitty_thread won't do anything, and likewise the update of hyperkitty_mailinglist_moderators if the list has no moderators
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan