From 3fd94dc0fa1c4671a84fda53096af665e4f9271e Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 9 Apr 2024 17:51:23 +0300 Subject: [PATCH] notification-check --- orm/notification.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/orm/notification.py b/orm/notification.py index 2b09ea11..02b57139 100644 --- a/orm/notification.py +++ b/orm/notification.py @@ -3,9 +3,11 @@ from enum import Enum as Enumeration from sqlalchemy import JSON, Column, ForeignKey, Integer, String from sqlalchemy.orm import relationship +from sqlalchemy.exc import ProgrammingError from orm.author import Author -from services.db import Base +from services.db import Base, engine +from services.logger import root_logger as logger class NotificationEntity(Enumeration): @@ -39,3 +41,11 @@ class Notification(Base): payload = Column(JSON, nullable=True) seen = relationship(lambda: Author, secondary='notification_seen') + + +try: + Notification.__table__.create(engine) + logger.info("Table `notification` was created.") +except ProgrammingError: + # Handle the exception here, for example by printing a message + logger.info("Table `notification` already exists.")