diff --git a/.travis.yml b/.travis.yml index f3f93f98..0f5dcef2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,23 @@ python: - "3.4" - "3.5" env: - - DJANGO="Django>=1.7.0,<1.8.0" - - DJANGO="Django>=1.8.0,<1.9.0" - - DJANGO="Django>=1.9.0,<1.10.0" - - DJANGO="Django>=1.10b1,<1.11.0" + # PostgreSQL + - DJANGO="Django>=1.7.0,<1.8.0" DB=postgresql DB_NAME=travis_ci_test + - DJANGO="Django>=1.8.0,<1.9.0" DB=postgresql DB_NAME=travis_ci_test + - DJANGO="Django>=1.9.0,<1.10.0" DB=postgresql DB_NAME=travis_ci_test + - DJANGO="Django>=1.10b1,<1.11.0" DB=postgresql DB_NAME=travis_ci_test + + # SQLite3 + - DJANGO="Django>=1.7.0,<1.8.0" DB=sqlite3 DB_NAME=db.sqlite3 + - DJANGO="Django>=1.8.0,<1.9.0" DB=sqlite3 DB_NAME=db.sqlite3 + - DJANGO="Django>=1.9.0,<1.10.0" DB=sqlite3 DB_NAME=db.sqlite3 + - DJANGO="Django>=1.10b1,<1.11.0" DB=sqlite3 DB_NAME=db.sqlite3 + + # MySQL + - DJANGO="Django>=1.7.0,<1.8.0" DB=mysql DB_NAME=mysql_db + - DJANGO="Django>=1.8.0,<1.9.0" DB=mysql DB_NAME=mysql_db + - DJANGO="Django>=1.9.0,<1.10.0" DB=mysql DB_NAME=mysql_db + - DJANGO="Django>=1.10b1,<1.11.0" DB=mysql DB_NAME=mysql_db matrix: allow_failures: @@ -24,6 +37,14 @@ matrix: install: - pip install -q $DJANGO - pip install -r requirements.txt + + # Handle PostgreSQL + - if [[ "$DB" = "postgresql" ]]; then pip install psycopg2; fi + - if [[ "$DB" = "postgresql" ]]; then psql -c 'create database travis_ci_test;' -U postgres; fi + + # Handle MySQL + - if [[ "$DB" = "mysql" ]]; then pip install mysqlclient; fi + - if [[ "$DB" = "mysql" ]]; then mysql -e 'create database mysql_db;'; fi script: - cd project diff --git a/project/project/settings.py b/project/project/settings.py index a775d902..d329fd3f 100644 --- a/project/project/settings.py +++ b/project/project/settings.py @@ -34,12 +34,14 @@ WSGI_APPLICATION = 'wsgi.application' -DB_NAME = os.path.join(BASE_DIR, 'db.sqlite3') +DB = os.environ['DB'] +if DB == 'postgresql': + DB = 'postgresql_psycopg2' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': DB_NAME + 'ENGINE': 'django.db.backends.' + DB, + 'NAME': os.environ['DB_NAME'] } }