Création des tables manquantes durant les mises à jour

tags/ipasserelle-im-0.2.18-1
Daniel Berteaud 12 years ago
parent 5464293b5b
commit abfc5ae5da
  1. 10
      root/etc/e-smith/templates/etc/e-smith/sql/init/80ejabberd

@ -5,11 +5,19 @@ my $pass = ${'ejabberd'}{'DbPassword'} || 'secret';
$OUT .= <<"END"; $OUT .= <<"END";
#! /bin/sh #! /bin/sh
SCHEMA=\$(rpm -ql ejabberd | grep mysql.sql)
if [ \! -d /var/lib/mysql/$db ]; then if [ \! -d /var/lib/mysql/$db ]; then
# If database doesn't exists, create it and load the schema
/usr/bin/mysqladmin create $db /usr/bin/mysqladmin create $db
for SQL in \$(rpm -qd ejabberd-modules | grep mysql.sql); do /usr/bin/mysql $db < \$SCHEMA
for SQL in \$(rpm -qd ejabberd-modules | grep mod_archive_odbc_mysql.sql); do
/usr/bin/mysql $db < \$SQL /usr/bin/mysql $db < \$SQL
done done
else
# If database exists, first drop actual indexes
grep -Pi '^CREATE(\ UNIQUE)?\ INDEX' \$SCHEMA | sed -e 's/CREATE/DROP/g' -e 's/(.*)//g' -e 's/USING BTREE //g' -e 's/UNIQUE //g' | /usr/bin/mysql -f $db
# and update the database (create missing tables and indexes)
sed -r -e 's/CREATE TABLE (.*) \\(/CREATE TABLE IF NOT EXISTS \\1 \\(/gi' \$SCHEMA | /usr/bin/mysql -f $db
fi fi
/usr/bin/mysql <<EOF /usr/bin/mysql <<EOF

Loading…
Cancel
Save