Project

General

Profile

migrate-keywords-to-tags.sh

Andreas Kohlbecker, 09/20/2016 06:35 PM

Download (642 Bytes)

 
1
#!/bin/bash
2

    
3
MYSQL_HOST=127.0.0.1
4
MYSQL_PORT=13306
5
MYSQL_USR='xxx'
6
MYSQL_PWD='xxx'
7
MYSQL_DB='redmine'
8

    
9
MYSQL="mysql -h $MYSQL_HOST -P$MYSQL_PORT -u$MYSQL_USR -p$MYSQL_PWD $MYSQL_DB"
10

    
11
#----------------------
12

    
13
# table custom_values fiels:
14
# id    customized_type   customized_id   custom_field_id value
15
    
16
echo 'SELECT * FROM custom_values c  WHERE c.custom_field_id=8  AND value IS NOT NULL' | $MYSQL > kdata
17

    
18
rm -f tags.sql taggings.sql
19

    
20
awk -f split-kdata.awk kdata
21

    
22
echo "Clearing tables"
23
echo "DELETE FROM tags; DELETE FROM taggings;" | $MYSQL
24
echo "Creating tags"
25
cat tags.sql | $MYSQL
26
echo "Creating taggings"
27
cat taggings.sql | $MYSQL
Add picture from clipboard (Maximum size: 40 MB)