add migrate file for delete html from answer content (copy from core branch - cleaningContent)

This commit is contained in:
Pavel 2024-06-17 17:33:23 +03:00
parent 01abb94a5e
commit 2fd9569574
2 changed files with 19 additions and 0 deletions

@ -0,0 +1,19 @@
UPDATE answer
SET content =
CASE
WHEN content ~ '<tr>|<td>' THEN
regexp_replace(content, '<\/?tr[^>]*>|<\/?td[^>]*>', '', 'g')
WHEN content ~ '<a download>[^<]+</a>' THEN
regexp_replace(content, '<a download>([^<]+)</a>', '\1', 'g')
WHEN content ~ '<img[^>]*src="([^"]*)"[^>]*' THEN
regexp_replace(content, '<img[^>]*src="\s*"[^>]*', '', 'g')
ELSE content
END;
UPDATE answer
SET content =
CASE
WHEN content ~ '<img' THEN
regexp_replace(content, '(.*?)(<img[^>]*src=["'']?([^"''>]+)["'']?[^>]*>)', '\1\3', 'g')
ELSE content
END;