2016-10-05 15:39:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Usage: ./scripts/client-upgrade-db.sh <module> <hostname> <user> <password> <db>
|
2019-10-30 14:52:53 +01:00
|
|
|
# Example: ./scripts/client-upgrade-db.sh Monarc\BackOffice localhost root derp monarc_backoffice
|
2016-10-05 15:39:48 +02:00
|
|
|
|
|
|
|
MODULE=$1
|
|
|
|
SQLHOST=$2
|
|
|
|
SQLUSER=$3
|
|
|
|
SQLPASS=$4
|
|
|
|
SQLBASE=$5
|
|
|
|
|
2017-03-17 11:39:47 +01:00
|
|
|
path=""
|
|
|
|
case $MODULE in
|
2019-10-30 14:52:53 +01:00
|
|
|
"Monarc/Core"|"core")
|
2017-03-17 11:39:47 +01:00
|
|
|
path="module/MonarcCore"
|
2017-03-17 14:38:22 +01:00
|
|
|
if [ ! -d $path ]; then
|
2017-03-17 11:39:47 +01:00
|
|
|
path="vendor/monarc/core"
|
|
|
|
fi
|
|
|
|
;;
|
2019-10-30 14:52:53 +01:00
|
|
|
"Monarc/BackOffice"|"backoffice")
|
|
|
|
path="module/Monarc/BackOffice"
|
2017-03-17 14:38:22 +01:00
|
|
|
if [ ! -d $path ]; then
|
2017-03-17 11:39:47 +01:00
|
|
|
path="vendor/monarc/backoffice"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknow module"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-10-05 15:39:48 +02:00
|
|
|
cat <<EOF >/tmp/conf.tmp.php
|
|
|
|
<?php
|
|
|
|
return array(
|
|
|
|
'paths' => array(
|
2017-03-17 11:39:47 +01:00
|
|
|
'migrations' => '$path/migrations/db',
|
|
|
|
'seeds' => '$path/migrations/seeds',
|
2016-10-05 15:39:48 +02:00
|
|
|
),
|
|
|
|
'environments' => array(
|
|
|
|
'default_migration_table' => 'phinxlog',
|
|
|
|
'default_database' => 'cli',
|
|
|
|
'cli' => array(
|
|
|
|
'adapter' => 'mysql',
|
|
|
|
'host' => '$SQLHOST',
|
|
|
|
'name' => '$SQLBASE',
|
|
|
|
'user' => '$SQLUSER',
|
|
|
|
'pass' => '$SQLPASS',
|
|
|
|
'port' => 3306,
|
|
|
|
'charset' => 'utf8',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
php ./vendor/robmorgan/phinx/bin/phinx migrate -c /tmp/conf.tmp.php
|
|
|
|
rm /tmp/conf.tmp.php
|