-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-sqlite-sqltemplates.sh
executable file
·72 lines (61 loc) · 1.52 KB
/
generate-sqlite-sqltemplates.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Copyright (c) 2024. Bernard Bou.
#
set -e
R='\u001b[31m'
G='\u001b[32m'
B='\u001b[34m'
Y='\u001b[33m'
M='\u001b[35m'
C='\u001b[36m'
Z='\u001b[0m'
modules="wn"
for m in ${modules}; do
echo -e "${Y}${m}${Z}"
templates_home="src/main/resources/${m}/sqltemplates"
for op in create index anchor cleanup; do
if [ ! -e "${templates_home}/mysql/${op}" ];then
continue
fi
for f in ${templates_home}/mysql/${op}/*-${op}.sql; do
b="`basename ${f}`"
d2="${templates_home}/sqlite/${op}"
mkdir -p "${d2}"
f2="${d2}/${b}"
echo -e "${M}${b}${Z}"
if [ ! -e "${f}" ]; then
echo -e "${R}${f}${Z}"
#else
# echo -e "${C}${f} -> ${f2}${Z}"
fi
cat ${f} | ./filter-flat.py | ./filter-mysql2sqlite.py > "${f2}"
done
done
done
exit
# DIRECT TEST TO A TEST DB
for m in ${modules}; do
echo -e "${Y}${m}${Z}"
templates_home="sql/"
for op in create index anchor cleanup; do
if [ ! -e "${templates_home}/mysql/${op}" ];then
continue
fi
for f in ${templates_home}/mysql/${op}/*-${op}.sql; do
b="`basename ${f}`"
d2="${templates_home}/sqlite/${op}"
mkdir -p "${d2}"
f2="${d2}/${b}"
echo -e "${M}${b}${Z}"
if [ ! -e "${f}" ]; then
echo -e "${R}${f}${Z}"
fi
if ! cat ${f} | ./filter-flat.py | ./filter-mysql2sqlite.py | sqlite3 test.db; then
echo -en "${R}"
cat ${f} | ./filter-flat.py | ./filter-mysql2sqlite.py
echo -en "${Z}"
fi
done
done
done