s4
changeset 824:fcf485cbabc6
At migration, translate direct-link to attachment files
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 20 Jun 2020 18:18:17 +0900 |
parents | ab6bb3efd40e |
children | e9817a71f332 |
files | s4-migrate.sh |
diffstat | 1 files changed, 29 insertions(+), 2 deletions(-) [+] |
line diff
1.1 --- a/s4-migrate.sh Fri Jun 19 15:32:57 2020 +0900 1.2 +++ b/s4-migrate.sh Sat Jun 20 18:18:17 2020 +0900 1.3 @@ -166,9 +166,36 @@ 1.4 | unhexize | sed -Ef "$sedfile2" | hexize` 1.5 echo "UPDATE dst.article_s SET val=X'$newval' WHERE rowid=$arid;" >>$sql 1.6 done 1.7 - echo "URL rewriting done." 1.8 - echo -n "Removing the group in the old world..." 1.9 + # Rewrite showattc Direct-Links 1.10 + attclinks=$( 1.11 + query <<-EOF 1.12 + SELECT group_concat(rowid, ',') FROM dst.article_s 1.13 + WHERE key='text' AND val LIKE '%?showattc+article_m+%' 1.14 + AND id IN (SELECT id FROM article WHERE blogid IN ($blogs)); 1.15 + EOF 1.16 + ) 1.17 + if [ -n "$attclinks" ]; then 1.18 + err attclinks=$attclinks 1.19 + sedfile3=${sedfile}3 1.20 + query <<-EOF > $sedfile3 1.21 + WITH attctrans AS ( 1.22 + SELECT s.rowid srcarid, d.rowid dstarid 1.23 + FROM main.article_m s NATURAL JOIN dst.article_m d 1.24 + WHERE d.id IN (SELECT id FROM dst.article 1.25 + WHERE blogid IN ($blogs)) 1.26 + ) SELECT printf('s/(\?showattc\+article_m)\+%s($|[^0-9])/\1+%s\2/g', 1.27 + srcarid, dstarid) 1.28 + FROM attctrans; 1.29 + EOF 1.30 + echo $attclinks | tr , '\n' | while read arid; do 1.31 + newval=`query "SELECT hex(val) FROM dst.article_s WHERE rowid=$arid;" \ 1.32 + | unhexize | sed -Ef "$sedfile3" | hexize` 1.33 + echo "UPDATE dst.article_s SET val=X'$newval' WHERE rowid=$arid;" 1.34 + done >> $sql 1.35 + fi 1.36 if [ -z "`query \".read $sql\"`" ]; then 1.37 + echo "URL rewriting done." 1.38 + echo -n "Removing the group in the old world..." 1.39 query <<-EOF 1.40 SAVEPOINT rmgroup; 1.41 DELETE FROM main.article WHERE blogid IN ($blogs);