Use utf8mb4 for connections to MySQL in dev
This commit is contained in:
Родитель
a5d81e1b6d
Коммит
c8e1a28208
|
@ -62,6 +62,10 @@ CORS_ENDPOINT_OVERRIDES = cors_endpoint_overrides(
|
|||
['localhost:3000', 'olympia.test']
|
||||
)
|
||||
|
||||
DATABASES = {
|
||||
'default': get_db_config('DATABASES_DEFAULT_URL', charset='utf8mb4'),
|
||||
}
|
||||
|
||||
# FxA config for local development only.
|
||||
FXA_CONFIG = {
|
||||
'default': {
|
||||
|
|
|
@ -46,8 +46,8 @@ INBOUND_EMAIL_DOMAIN = env('INBOUND_EMAIL_DOMAIN',
|
|||
default='addons-dev.allizom.org')
|
||||
|
||||
DATABASES = {
|
||||
'default': get_db_config('DATABASES_DEFAULT_URL'),
|
||||
'slave': get_db_config('DATABASES_SLAVE_URL', atomic_requests=False),
|
||||
'default': get_db_config('DATABASES_DEFAULT_URL', charset='utf8mb4'),
|
||||
'slave': get_db_config('DATABASES_SLAVE_URL', atomic_requests=False, charset='utf8mb4'),
|
||||
}
|
||||
|
||||
SERVICES_DATABASE = get_db_config('SERVICES_DATABASE_URL')
|
||||
|
|
|
@ -123,7 +123,9 @@ def cors_endpoint_overrides(whitelist_endpoints):
|
|||
CORS_ENDPOINT_OVERRIDES = []
|
||||
|
||||
|
||||
def get_db_config(environ_var, atomic_requests=True):
|
||||
def get_db_config(environ_var, atomic_requests=True, charset='utf8'):
|
||||
assert charset in ('utf8', 'utf8mb4')
|
||||
|
||||
values = env.db(
|
||||
var=environ_var,
|
||||
default='mysql://root:@localhost/olympia')
|
||||
|
@ -137,12 +139,15 @@ def get_db_config(environ_var, atomic_requests=True):
|
|||
'CONN_MAX_AGE': 300,
|
||||
'ENGINE': 'olympia.core.db.mysql',
|
||||
'OPTIONS': {
|
||||
'charset': charset,
|
||||
'sql_mode': 'STRICT_ALL_TABLES',
|
||||
'isolation_level': 'read committed'
|
||||
},
|
||||
'TEST': {
|
||||
'CHARSET': 'utf8',
|
||||
'COLLATION': 'utf8_general_ci'
|
||||
'CHARSET': charset,
|
||||
'COLLATION': (
|
||||
'utf8_general_ci' if charset == 'utf8' else
|
||||
'utf8mb4_general_ci')
|
||||
},
|
||||
})
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче