mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-24 06:48:35 +02:00
Django automatically renames test databases to 'test_%s' % settings.DATABASES[*]["NAME"], so modoboa_test became test_modoboa_test. There's no point creating the database in `before script` as the test suite creates it. https://docs.djangoproject.com/en/1.11/topics/testing/advanced/#django.db.connection.creation.create_test_db - target oldest currently supported database servers, travis currently defaults to PostgreSQL 9.2 which isn't supported anymore. - move database dependencies out of travis.yml into test_requirements.txt and pin to minimum versions recommended by django. See https://docs.djangoproject.com/en/1.11/ref/databases/ - use MySQL root user for tests, we already use the root user (postgres) for PostgreSQL. - fix typo in modoboa/test_settings for DB variable, default should be POSTGRESQL not POSTGRES - enable MySQL strict mode (on by default on MySQL >= 5.7) See https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-sql-mode
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import os
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
|
|
|
|
DB = os.environ.get('DB', 'POSTGRESQL')
|
|
|
|
if DB == 'MYSQL':
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
'NAME': 'modoboa',
|
|
'USER': 'root',
|
|
'PASSWORD': '',
|
|
'HOST': 'localhost',
|
|
'PORT': '',
|
|
'ATOMIC_REQUESTS': True,
|
|
# MySQL's Strict Mode fixes many data integrity problems in MySQL,
|
|
# such as data truncation upon insertion, by escalating warnings
|
|
# into errors. It is strongly recommended you activate it.
|
|
# MySQL >= 5.7 set STRICT_TRANS_TABLES by default
|
|
# See: https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-sql-mode
|
|
'OPTIONS': {
|
|
'init_command': 'SET sql_mode=\'STRICT_TRANS_TABLES\'',
|
|
},
|
|
},
|
|
}
|
|
elif DB == 'SQLITE':
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': 'modoboa.db',
|
|
'PORT': '',
|
|
'ATOMIC_REQUESTS': True,
|
|
},
|
|
}
|
|
else:
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': 'modoboa',
|
|
'USER': 'postgres',
|
|
'PASSWORD': '',
|
|
'HOST': 'localhost',
|
|
'PORT': '',
|
|
'ATOMIC_REQUESTS': True,
|
|
},
|
|
}
|