merged
This commit is contained in:
@@ -7,7 +7,18 @@ from orm.shout import Shout
|
||||
from orm.topic import Topic, TopicFollower
|
||||
from orm.user import User, UserRating
|
||||
|
||||
# NOTE: keep orm module isolated
|
||||
|
||||
def init_tables():
|
||||
Base.metadata.create_all(engine)
|
||||
Operation.init_table()
|
||||
Resource.init_table()
|
||||
User.init_table()
|
||||
Community.init_table()
|
||||
Role.init_table()
|
||||
UserRating.init_table()
|
||||
Shout.init_table()
|
||||
print("[orm] tables initialized")
|
||||
|
||||
|
||||
__all__ = [
|
||||
"User",
|
||||
@@ -21,16 +32,5 @@ __all__ = [
|
||||
"Notification",
|
||||
"Reaction",
|
||||
"UserRating",
|
||||
"init_tables"
|
||||
]
|
||||
|
||||
|
||||
def init_tables():
|
||||
Base.metadata.create_all(engine)
|
||||
Operation.init_table()
|
||||
Resource.init_table()
|
||||
User.init_table()
|
||||
Community.init_table()
|
||||
Role.init_table()
|
||||
UserRating.init_table()
|
||||
Shout.init_table()
|
||||
print("[orm] tables initialized")
|
||||
|
@@ -1,13 +1,25 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, String, JSON, ForeignKey, DateTime, Boolean
|
||||
from services.db import Base
|
||||
from sqlalchemy import Column, Enum, ForeignKey, DateTime, Boolean, Integer
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
|
||||
from base.orm import Base
|
||||
from enum import Enum as Enumeration
|
||||
|
||||
|
||||
class NotificationType(Enumeration):
|
||||
NEW_REACTION = 1
|
||||
NEW_SHOUT = 2
|
||||
NEW_FOLLOWER = 3
|
||||
|
||||
|
||||
class Notification(Base):
|
||||
__tablename__ = "notification"
|
||||
|
||||
shout = Column(ForeignKey("shout.id"), index=True)
|
||||
reaction = Column(ForeignKey("reaction.id"), index=True)
|
||||
user = Column(ForeignKey("user.id"), index=True)
|
||||
createdAt = Column(DateTime, nullable=False, default=datetime.now, index=True)
|
||||
seen = Column(Boolean, nullable=False, default=False, index=True)
|
||||
type = Column(String, nullable=False)
|
||||
data = Column(JSON, nullable=True)
|
||||
type = Column(Enum(NotificationType), nullable=False)
|
||||
data = Column(JSONB, nullable=True)
|
||||
occurrences = Column(Integer, default=1)
|
||||
|
Reference in New Issue
Block a user