From b7fe5de12be5c9f02adeedba45befee751ea68be Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 14 May 2018 20:42:41 +0100 Subject: Migration runner and migrations (#69) * Migration runner and migrations * Remove demo wiki data * [Staff] Table management pages * Fix weird travis build omission * Address review and comments by @Volcyy * [Tables] Fix pagination * Move table definitions to new file with nameduple * Linting * Address lemon's review comments * Address @Volcyy's review * Address lemon's review * Update search placeholder * Search by key now available --- pysite/route_manager.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'pysite/route_manager.py') diff --git a/pysite/route_manager.py b/pysite/route_manager.py index 429a553e..f99a4736 100644 --- a/pysite/route_manager.py +++ b/pysite/route_manager.py @@ -6,11 +6,12 @@ import os from flask import Blueprint, Flask, _request_ctx_stack from flask_dance.contrib.discord import make_discord_blueprint from flask_sockets import Sockets +from gunicorn_config import when_ready from pysite.base_route import APIView, BaseView, ErrorView, RouteView from pysite.constants import ( - CSRF, DISCORD_OAUTH_AUTHORIZED, DISCORD_OAUTH_ID, DISCORD_OAUTH_REDIRECT, DISCORD_OAUTH_SCOPE, - DISCORD_OAUTH_SECRET, PREFERRED_URL_SCHEME) + CSRF, DEBUG_MODE, DISCORD_OAUTH_AUTHORIZED, DISCORD_OAUTH_ID, DISCORD_OAUTH_REDIRECT, + DISCORD_OAUTH_SCOPE, DISCORD_OAUTH_SECRET, PREFERRED_URL_SCHEME) from pysite.database import RethinkDB from pysite.oauth import OauthBackend from pysite.websockets import WS @@ -40,6 +41,10 @@ class RouteManager: # to edit self.app.config["WTF_CSRF_TIME_LIMIT"] = None + if DEBUG_MODE: + # Migrate the database, as we would in prod + when_ready(output_func=self.db.log.info) + self.app.before_request(self.db.before_request) self.app.teardown_request(self.db.teardown_request) -- cgit v1.2.3