feat: Update SQLAlchemy column definition in web UI models

This commit updates the SQLAlchemy column definition in models.py to use the `Identity` class for the `id` column in the `UserRecoveryCodes` table. This change ensures that the `id` column is automatically populated with an incrementing value starting from 1.
This commit is contained in:
Théophile Diot 2024-08-02 09:10:43 +01:00
parent 697dd4447f
commit a84826c75f
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -10,7 +10,7 @@ for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in ((
from bcrypt import checkpw
from flask_login import AnonymousUserMixin, UserMixin
from sqlalchemy.orm import declarative_base, relationship
from sqlalchemy import Boolean, DateTime, Column, Integer, String, ForeignKey, UnicodeText, func
from sqlalchemy import Boolean, DateTime, Column, Identity, Integer, String, ForeignKey, UnicodeText, func
from model import METHODS_ENUM # type: ignore
@ -100,7 +100,7 @@ class RolesUsers(Base):
class UserRecoveryCodes(Base):
__tablename__ = "bw_ui_user_recovery_codes"
id = Column(Integer, primary_key=True)
id = Column(Integer, Identity(start=1, increment=1), primary_key=True)
user_name = Column(String(256), ForeignKey("bw_ui_users.username", onupdate="cascade", ondelete="cascade"), nullable=False)
code = Column(UnicodeText, nullable=False)