Any way to change urls in posts to a new url from the backend/database by an sql statement/similar
Hi All.
Is there any way to bulk change url through a backend process?
For example, if posts contain links and those links have changed due to a tool change.
The thing that needs to happen is to take a docid in the old url and paste it behind a new url.
This could be done manually of course but if you're looking at volume of 50.000 one has to wonder if there is no way to do this on the backend. Today I can search for the old url string and find the results in the posts so I am sure there must be a search/replace statement that can be run on the backend?
Any Database/table guru out there?
Thanks for brainstorming with me!
Wendy
Hi Wendy,
lovely task you are outlining there. Theoretically SQL knows about a REPLACE() function to replace substrings in one call, but unfortunately that never made it to LiQL. Arguably it's not the most common activity on a community dataset :)
You would need to approach this in a script with three steps:
- Pull all matching messages and their ID via a SELECT id, body FROM messages WHERE body matches ('yourstring') call
- For each message retrieved in the 1st step perform a substring replace.
- Write the updated message back via the UPDATE function
All the needed LiQL functions and parameters are described in the API v2 documentation on the message resource. This can be done as a tool with almost any script language or also realized on platform via a Lithium custom component.
While you are at it you might consider future proofing this approach for the next url update in 3 years ;) For example you could move the urls into a new custom data field that would be easier to update. This would require then to update your message UI to show this additional link in a separate UI element.