diff --git a/api/models/account.py b/api/models/account.py index cc2c30202f..7ffeefa980 100644 --- a/api/models/account.py +++ b/api/models/account.py @@ -4,7 +4,7 @@ from typing import Optional, cast from flask_login import UserMixin # type: ignore from sqlalchemy import func -from sqlalchemy.orm import Mapped, mapped_column +from sqlalchemy.orm import Mapped, mapped_column, reconstructor from models.base import Base @@ -81,8 +81,6 @@ class AccountStatus(enum.StrEnum): class Account(UserMixin, Base): - role: Optional["TenantAccountRole"] = None - _current_tenant: Optional["Tenant"] = None __tablename__ = "accounts" __table_args__ = (db.PrimaryKeyConstraint("id", name="account_pkey"), db.Index("account_email_idx", "email")) @@ -103,6 +101,11 @@ class Account(UserMixin, Base): created_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp()) updated_at = db.Column(db.DateTime, nullable=False, server_default=func.current_timestamp()) + @reconstructor + def init_on_load(self): + self.role: Optional[TenantAccountRole] = None + self._current_tenant: Optional[Tenant] = None + @property def is_password_set(self): return self.password is not None