Merge pull request #87 from Discours/feature/migration_fix_and_notification_schema

Migration fix, notification schema update
This commit is contained in:
Ilya Y 2023-10-09 13:54:12 +03:00 committed by GitHub
commit ca77f6c5fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 328 additions and 304 deletions

View File

@ -70,7 +70,6 @@ def create_author_from_app(app):
"username": app["email"],
"email": app["email"],
"name": app.get("name", ""),
"bio": app.get("bio", ""),
"emailConfirmed": False,
"slug": slug,
"createdAt": ts,
@ -149,6 +148,7 @@ async def migrate(entry, storage):
"deletedAt": date_parse(entry.get("deletedAt")) if entry.get("deletedAt") else None,
"createdAt": date_parse(entry.get("createdAt", OLD_DATE)),
"updatedAt": date_parse(entry["updatedAt"]) if "updatedAt" in entry else ts,
"createdBy": author.id,
"topics": await add_topics_follower(entry, storage, author),
"body": extract_html(entry, cleanup=True)
}

View File

@ -21,7 +21,6 @@ def migrate(entry):
"createdAt": parse(entry["createdAt"]),
"emailConfirmed": ("@discours.io" in email) or bool(entry["emails"][0]["verified"]),
"muted": False, # amnesty
"bio": entry["profile"].get("bio", ""),
"links": [],
"name": "anonymous",
"password": entry["services"]["password"].get("bcrypt")
@ -29,7 +28,7 @@ def migrate(entry):
if "updatedAt" in entry:
user_dict["updatedAt"] = parse(entry["updatedAt"])
if "wasOnineAt" in entry:
if "wasOnlineAt" in entry:
user_dict["lastSeen"] = parse(entry["wasOnlineAt"])
if entry.get("profile"):
# slug

View File

@ -1,13 +1,22 @@
from datetime import datetime
from sqlalchemy import Column, String, JSON, ForeignKey, DateTime, Boolean
from sqlalchemy import Column, Enum, JSON, ForeignKey, DateTime, Boolean, Integer
from base.orm import Base
from enum import Enum as Enumeration
class NotificationType(Enumeration):
NEW_COMMENT = 1
NEW_REPLY = 2
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)
type = Column(Enum(NotificationType), nullable=False)
data = Column(JSON, nullable=True)
occurrences = Column(Integer, default=1)

View File

@ -500,3 +500,19 @@ type Chat {
unread: Int
private: Boolean
}
enum NotificationType {
NEW_COMMENT,
NEW_REPLY
}
type Notification {
id: Int!
shout: Int
reaction: Int
type: NotificationType
createdAt: DateTime!
seen: Boolean!
data: String # JSON
occurrences: Int!
}