Added postgresql support.

This commit is contained in:
Martin Edenhofer 2016-01-20 01:06:00 +01:00
parent a00be78195
commit b48ed93e9d
3 changed files with 78 additions and 26 deletions

View file

@ -21,10 +21,25 @@ coffeelint:
script:
- coffeelint app/
job_unit:
job_unit_mysql:
stage: test
tags:
- core
- mysql
script:
- export RAILS_ENV=test
- rake db:drop;
- rake db:create
- rake db:migrate
- rake db:seed
- rake test:units
- rake test:controllers
job_unit_postgresql:
stage: test
tags:
- core
- postgresql
script:
- export RAILS_ENV=test
- rake db:drop;

View file

@ -5,7 +5,13 @@ if [ "$RNAME" == '' ]; then
exit 1
fi
DBNAME=$RNAME
if [ "$RDB" == '' ]; then
echo "ERROR: Env RDB is missing!"
exit 1
fi
export RAND=`perl -e 'print rand(99999999)*100000'`
DBNAME="$RNAME-$RAND"
DBFILE=config/database.yml
DB_PRODUCTION=$DBNAME"_production"
DB_TEST=$DBNAME"_test"
@ -13,27 +19,56 @@ DB_DEVELOPMENT=$DBNAME"_development"
echo "Creating $DBFILE for tests with $DBNAME"
echo "production:" > $DBFILE
echo " adapter: mysql2" >> $DBFILE
echo " database: $DB_PRODUCTION" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password:" >> $DBFILE
echo "test:" >> $DBFILE
echo " adapter: mysql2" >> $DBFILE
echo " database: $DB_TEST" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password:" >> $DBFILE
echo "development:" >> $DBFILE
echo " adapter: mysql2" >> $DBFILE
echo " database: $DB_DEVELOPMENT" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password:" >> $DBFILE
if [ "$RDB" == 'mysql' ]; then
echo "production:" > $DBFILE
echo " adapter: mysql2" >> $DBFILE
echo " database: $DB_PRODUCTION" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password:" >> $DBFILE
echo "test:" >> $DBFILE
echo " adapter: mysql2" >> $DBFILE
echo " database: $DB_TEST" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password:" >> $DBFILE
echo "development:" >> $DBFILE
echo " adapter: mysql2" >> $DBFILE
echo " database: $DB_DEVELOPMENT" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password:" >> $DBFILE
fi
if [ "$RDB" == 'postgresql' ]; then
echo "production:" > $DBFILE
echo " adapter: postgresql" >> $DBFILE
echo " database: $DB_PRODUCTION" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password: pass" >> $DBFILE
echo "test:" >> $DBFILE
echo " adapter: postgresql" >> $DBFILE
echo " database: $DB_TEST" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password: pass" >> $DBFILE
echo "development:" >> $DBFILE
echo " adapter: postgresql" >> $DBFILE
echo " database: $DB_DEVELOPMENT" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password: pass" >> $DBFILE
fi

View file

@ -8,4 +8,6 @@ script/scheduler.rb stop
script/websocket-server.rb stop
kill $(cat tmp/pids/puma.pid)
rake db:drop
exit $EXIT