Skip to content

Commit

Permalink
Migrate database to PostgreSQL
Browse files Browse the repository at this point in the history
References #92
  • Loading branch information
u8sand committed Dec 11, 2018
1 parent 7f28e1d commit e4fcc35
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions FAIRshake/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,22 @@
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

MYSQL_CONFIG = os.environ.get(
'MYSQL_CONFIG',
'/ssl/my.cnf' if os.path.isfile('/ssl/my.cnf') else None
)
try:
POSTGRESQL_CONFIG_FILE = os.environ.get(
'POSTGRESQL_CONFIG_FILE',
'/ssl/psql.json' if os.path.isfile('/ssl/psql.json') else None
)
POSTGRESQL_CONFIG = json.load(open(POSTGRESQL_CONFIG_FILE, 'r'))
except:
POSTGRESQL_CONFIG = None

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
} if MYSQL_CONFIG is None else {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': MYSQL_CONFIG,
},
}
} if POSTGRESQL_CONFIG is None else dict({
'ENGINE': 'django.db.backends.postgresql',
}, **POSTGRESQL_CONFIG)
}


Expand Down

0 comments on commit e4fcc35

Please sign in to comment.