Modifying the database inside of a backup to remove a duplicate key tag so that it doesn't fail when restoring

Thanks for all your help. I’ve unzipped the files, edited the duplicate tag again and then very carefully rezipped paying extra careful attention to the file name, and there is progress!

Now when restoring i see this error message, which appears to be far more common:

[2023-08-25 15:25:21] CREATE INDEX
[2023-08-25 15:25:21] ERROR:  could not create unique index "index_tags_on_lower_name"
[2023-08-25 15:25:21] DETAIL:  Key (lower(name::text))=(socialmedia) is duplicated.
[2023-08-25 15:25:21] EXCEPTION: psql failed: DETAIL:  Key (lower(name::text))=(socialmedia) is duplicated.

I’d guess that means that i have changed the tag successfully, but there are still some occurrences of the tag in posts in my database. The tag_id number says there should be a tag called socialmedia but instead its finding a tag called socialmedia2 which is causing a conflict.

this post and this one discuss fixes, but as i only have access to my backup via directly editing the code on my local machine i’m not able to use the mysql tools to help clean it up.

Fortunately in my database i’ve only got 38 instances of 'socialmedia' (as oppose to 50,000+ socialmedia occurrences). Assuming I was correct changing the one on line 395421 as i screenshotted above, then I can’t see how to tell which remaining ones are linked to the ‘socialmedia’ tag, and which to the tag i’ve edited to ‘socialmedia2’.

Here’s an example of a fairly short post using the socialmedia tag

9488	'/groups/communitybuilders':86 '/groups/socialmedia':84 '/groups/webdev':89 '1st':117 '2022':131 '6':125 'activ':61 'banner':113 'btw':143 'close':169 'comment':21 'communiti':47 'communitybuild':87 'concept':4A 'especi':28 'event':119 'excit':164 'feedback':8B 'final':166 'get':38,133 'github':94 'grow':6A,142 'hack':127 'hard':156 'help':96 'homepag':151 'host':124 'improv':11B 'join':71,106 'launch':41,118,126 'like':128 'link':110 'live':140,175 'lot':27 'love':1A,67 'marvelxi':152 'mean':25 'media':51 'member':62 'mention':93 'move':45 'much':15 'new':150 'one':72,107 'onto':53 'plan':121 'platform':7B,43,139 'pleas':5A 'project':137 'promot':97 're':33,36,56,161 'readi':39,172 'rhorho358':23 'right':63 'see':100,167 'site':176 'slight':76,177,179 'small':58 'smile':77,178,180 'social':50 'socialmedia':85 'stage':31 'suggest':10B 'sure':79 'take':17 'team':59,75,103 'thank':12 'think':147 'time':19 'use':108 'webdev':90 'websit':3A 'whether':80 'work':155 'would':66,82	Thank you so much for taking the time to comment here @R , it means a lot, especially in the st... has been working hard on it and we’re all very excited to finally see it close to being ready on the live site :slight_smile: :slight_smile:	en_GB	4	f

I might be on the wrong track here though as that does look like more tags at the start than a user is likely to use in a post. Also possible that ‘socialmedia’ isn’t a tag used in the above post, although it should have been.