scripts: Add client upgrade DB script

remotes/origin/master
Guillaume Lesniak 2016-10-05 15:39:48 +02:00
parent 6228c581fb
commit 9f84040043
1 changed files with 38 additions and 0 deletions

38
scripts/client-upgrade-db.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# Usage: ./scripts/client-upgrade-db.sh <module> <hostname> <user> <password> <db>
# Example: ./scripts/client-upgrade-db.sh MonarcBO localhost root derp monarc_backoffice
MODULE=$1
SQLHOST=$2
SQLUSER=$3
SQLPASS=$4
SQLBASE=$5
cat <<EOF >/tmp/conf.tmp.php
<?php
return array(
'paths' => array(
'migrations' => 'module/$MODULE/migrations/db',
'seeds' => 'module/$MODULE/migrations/seeds',
),
'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