Add psycopg2 as an optional dependency and throw error at startup if db is not initialized

This commit is contained in:
Tulir Asokan
2019-08-07 00:00:59 +03:00
parent b4a1aacd12
commit 47cf63e0e6
4 changed files with 11 additions and 2 deletions
+5
View File
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from itertools import chain
import sys
from alchemysession import AlchemySessionContainer
@@ -57,6 +58,10 @@ class TelegramBridge(Bridge):
def prepare_db(self) -> None:
super().prepare_db()
if not self.db.has_table("alembic_version"):
self.log.critical("alembic_version table not found. "
"Did you forget to `alembic upgrade head`?")
sys.exit(10)
init_db(self.db)
self.session_container = AlchemySessionContainer(
engine=self.db, table_base=Base, session=False,