[2e23dc]: dist / bin / dump-standard.sh  Maximize  Restore  History

Download this file

121 lines (108 with data), 3.5 kB

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# bbou@ac-toulouse.fr
# 25/11/2013
# [--schema] 30|31|31_snapshot
schema=
if [ "$1" == "--schema" ]; then
schema=true
shift
fi
dbtag=$1
shift
if [ -z "${dbtag}" ]; then
echo "$0 <dbtag:30|31|31_snapshot>"
exit 1
fi
# D A T A B A S E
dbms=standard
indbms=mysql
# D I R S
distdir="`dirname $(readlink -m $0)`/"
distdir="$(readlink -m ${distdir}/..)"
#echo "distdir=${distdir}"
outdir=${distdir}/data/${dbms}/${dbtag}
outdir="$(readlink -m ${outdir})"
#echo "outdir=${outdir}"
builderdir=${distdir}/../run
builderdir="$(readlink -m ${builderdir})"
#echo "builderdir=${builderdir}"
indir=${distdir}/data/${indbms}
indir="$(readlink -m ${indir})"
#echo "indir=${indir}"
wn="words casedwords senses synsets linktypes semlinks lexlinks postypes lexdomains morphmaps morphs samples vframemaps vframes vframesentencemaps vframesentences adjpositions adjpositiontypes"
lsenses="senses20 senses21"
lsensemaps="sensemaps2021 sensemaps2130"
lsynsetmaps=""
lcomputedsensemaps=""
case ${dbtag} in
30)
lsenses="${lsenses}"
lcomputedsensemaps=""
lsynsetmaps="synsetmaps2030 synsetmaps2130"
;;
31)
lsenses="${lsenses} senses30"
lcomputedsensemaps="sensemaps3031"
lsynsetmaps="synsetmaps2031 synsetmaps2131 synsetmaps3031"
;;
31_snapshot*)
lsenses="${lsenses} senses30 senses31"
lcomputedsensemaps="sensemaps3031 sensemaps3131_snapshot"
lsynsetmaps="synsetmaps2031_snapshot synsetmaps2131_snapshot synsetmaps3031_snapshot synsetmaps3131_snapshot"
;;
*)
echo "illegal dbtag ${dbtag}"
exit 1
esac
legacy="${lsenses} ${lsensemaps} ${lsynsetmaps} ${lcomputedsensemaps}"
vn="vnclasses vnclassmembers vnclassmembersenses vngroupings vngroupingmaps vnrolemaps vnroles vnroletypes vnselrestrs vnselrestrtypes vnframemaps vnframes vnframenames vnframesubnames vnsemantics vnsyntaxes vnpredicatemaps vnpredicates vnexamplemaps vnexamples"
bnc="bncs bncimaginfs bncconvtasks bncspwrs"
sumo="sumofiles sumoformulas sumoterms sumotermattrs sumomaps sumoparsemaps"
xwn="xwnparselfts xwnwsds"
glf="glfs"
ilfwn="ilfs"
logs="logs"
# D O M A I N S
extensions="legacy vn bnc sumo xwn glf ilfwn logs"
domains="wn ${extensions}"
# F U N C T I O N S
function data()
{
mytables=$1
mydomain=$2
echo "* dumping data of ${mytables} from `basename ${indir}`/${dbtag}"
${distdir}/bin/filter-normalize.sh < ${indir}/${dbtag}/${indbms}-${mydomain}-data.sql > ${outdir}/standard-${mydomain}-data.sql
}
function schema()
{
mytables=$1
mydomain=$2
echo "* dumping schema of ${mytables}"
${builderdir}/bin/run-${dbms}.sh dump table creates ${mydomain} > ${outdir}/${dbms}-${mydomain}-schema.sql 2> /dev/null
}
function constraints()
{
mydomain=$1
myswitch=${mydomain}
echo "* dumping views ${mydomain}"
${builderdir}/bin/run-${dbms}-${dbtag}.sh dump ${mydomain} constraint creates > ${outdir}/${dbms}-${mydomain}-constrain.sql 2> /dev/null
${builderdir}/bin/run-${dbms}-${dbtag}.sh dump ${mydomain} constraint drops > ${outdir}/${dbms}-${mydomain}-unconstrain.sql 2> /dev/null
}
function views()
{
mydomain=$1
myswitch=${mydomain}
echo "* dumping constraints ${mydomain}"
${builderdir}/bin/run-${dbms}.sh dump ${mydomain} view creates > ${outdir}/${dbms}-${mydomain}-views.sql 2> /dev/null
}
rm -fR ${outdir}
mkdir -p ${outdir}
for domain in ${domains}; do
eval tables=\$${domain}
data "${tables}" "${domain}"
if [ ! -z "$schema" ]; then
schema "${tables}" "${domain}"
constraints "${domain}"
views "${domain}"
fi
done