feature/migrations, closes #19 #20
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered)
|
||||
|
||||
from sqlalchemy import event
|
||||
from pathlib import Path
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered)
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
|
@ -14,8 +16,8 @@ class Notification(db.Model, ModelSerializeMixin):
|
|||
|
||||
user_id_: int = db.Column("user", Serial, db.ForeignKey("user.id"), nullable=False)
|
||||
plugin_id_: int = db.Column("plugin", Serial, db.ForeignKey("plugin.id"), nullable=False)
|
||||
user_: "User" = db.relationship("User")
|
||||
plugin_: "Plugin" = db.relationship(
|
||||
user_: User = db.relationship("User")
|
||||
plugin_: Plugin = db.relationship(
|
||||
"Plugin", backref=db.backref("notifications_", cascade="all, delete, delete-orphan")
|
||||
)
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered)
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..database import db
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered)
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from secrets import compare_digest
|
||||
|
||||
from .. import logger
|
||||
from ..database import db
|
||||
from ..database.types import ModelSerializeMixin, UtcDateTime, Serial
|
||||
|
||||
from flaschengeist import logger
|
||||
|
||||
|
||||
class Session(db.Model, ModelSerializeMixin):
|
||||
"""Model for a Session
|
||||
|
@ -26,7 +27,7 @@ class Session(db.Model, ModelSerializeMixin):
|
|||
|
||||
_id = db.Column("id", Serial, primary_key=True)
|
||||
_user_id = db.Column("user_id", Serial, db.ForeignKey("user.id"))
|
||||
user_: "User" = db.relationship("User", back_populates="sessions_")
|
||||
user_: User = db.relationship("User", back_populates="sessions_")
|
||||
|
||||
@property
|
||||
def userid(self):
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered)
|
||||
|
||||
from typing import Optional
|
||||
from datetime import date, datetime
|
||||
from sqlalchemy.orm.collections import attribute_mapped_collection
|
||||
|
@ -62,10 +64,10 @@ class User(db.Model, ModelSerializeMixin):
|
|||
# Protected stuff for backend use only
|
||||
id_ = db.Column("id", Serial, primary_key=True)
|
||||
roles_: list[Role] = db.relationship("Role", secondary=association_table, cascade="save-update, merge")
|
||||
sessions_: list["Session"] = db.relationship(
|
||||
sessions_: list[Session] = db.relationship(
|
||||
"Session", back_populates="user_", cascade="all, delete, delete-orphan"
|
||||
)
|
||||
avatar_: Optional["Image"] = db.relationship("Image", cascade="all, delete, delete-orphan", single_parent=True)
|
||||
avatar_: Optional[Image] = db.relationship("Image", cascade="all, delete, delete-orphan", single_parent=True)
|
||||
reset_requests_: list["_PasswordReset"] = db.relationship("_PasswordReset", cascade="all, delete, delete-orphan")
|
||||
|
||||
# Private stuff for internal use
|
||||
|
|
Loading…
Reference in New Issue