Skip to content
Snippets Groups Projects
Verified Commit 1b374eb2 authored by Tanner Prestegard's avatar Tanner Prestegard
Browse files

Temporarily remove database routing for production

Not working as expected, so we are going to have to revisit this
feature in the near future.
parent 3e3b7665
No related branches found
No related tags found
No related merge requests found
......@@ -16,37 +16,37 @@ if (isinstance(is_priority_server, str) and
is_priority_server.lower() in ['true', 't']):
PRIORITY_SERVER = True
# If priority server, do some things
if PRIORITY_SERVER:
# Add custom permissions for API
default_perms = list(REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'])
default_perms = ['api.permissions.IsPriorityUser'] + default_perms
REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = tuple(default_perms)
# Don't do anything to databases. Priority servers use the master
# for both read and write operations
else:
# If not a priority server, we use the read-only replica database
# for reads and master for writes.
# The username, password, and database name are all replicated
# from the production database
# Set up dict and add to DATABASES setting
read_replica = {
'NAME': DATABASES['default']['NAME'],
'ENGINE': 'django.db.backends.mysql',
'USER': DATABASES['default']['USER'],
'PASSWORD': DATABASES['default']['PASSWORD'],
'HOST': os.environ.get('DJANGO_REPLICA_DB_HOST', ''),
'PORT': os.environ.get('DJANGO_REPLICA_DB_PORT', ''),
'OPTIONS': {
'init_command': 'SET storage_engine=MyISAM',
},
}
DATABASES['read_replica'] = read_replica
# Set up database router
DATABASE_ROUTERS = ['core.db.routers.NonPriorityRouter',]
## If priority server, do some things
#if PRIORITY_SERVER:
# # Add custom permissions for API
# default_perms = list(REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'])
# default_perms = ['api.permissions.IsPriorityUser'] + default_perms
# REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = tuple(default_perms)
#
# # Don't do anything to databases. Priority servers use the master
# # for both read and write operations
#else:
# # If not a priority server, we use the read-only replica database
# # for reads and master for writes.
# # The username, password, and database name are all replicated
# # from the production database
#
# # Set up dict and add to DATABASES setting
# read_replica = {
# 'NAME': DATABASES['default']['NAME'],
# 'ENGINE': 'django.db.backends.mysql',
# 'USER': DATABASES['default']['USER'],
# 'PASSWORD': DATABASES['default']['PASSWORD'],
# 'HOST': os.environ.get('DJANGO_REPLICA_DB_HOST', ''),
# 'PORT': os.environ.get('DJANGO_REPLICA_DB_PORT', ''),
# 'OPTIONS': {
# 'init_command': 'SET storage_engine=MyISAM',
# },
# }
# DATABASES['read_replica'] = read_replica
#
# # Set up database router
# DATABASE_ROUTERS = ['core.db.routers.NonPriorityRouter',]
# Safety check on debug mode for production
if (DEBUG == True):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment