diff --git a/api/kiwi_vpn_api/db/models.py b/api/kiwi_vpn_api/db/models.py index 421dbed..633e78a 100644 --- a/api/kiwi_vpn_api/db/models.py +++ b/api/kiwi_vpn_api/db/models.py @@ -18,7 +18,7 @@ class User(ORMBaseModel): __tablename__ = "users" name = Column(String, primary_key=True, index=True) - password = Column(String) + password = Column(String, nullable=False) capabilities: list[UserCapability] = relationship( "UserCapability", lazy="joined", cascade="all, delete-orphan" @@ -60,14 +60,14 @@ class DistinguishedName(ORMBaseModel): id = Column(Integer, primary_key=True, autoincrement=True) owner_name = Column(String, ForeignKey("users.name")) - cn_only = Column(Boolean, default=True) + cn_only = Column(Boolean, default=True, nullable=False) country = Column(String(2)) state = Column(String) city = Column(String) organization = Column(String) organizational_unit = Column(String) email = Column(String) - common_name = Column(String) + common_name = Column(String, nullable=False) UniqueConstraint( country, @@ -86,7 +86,13 @@ class Certificate(ORMBaseModel): id = Column(Integer, primary_key=True, autoincrement=True) owner_name = Column(String, ForeignKey("users.name")) - dn_id = Column(Integer, ForeignKey("distinguished_names.id")) + dn_id = Column( + Integer, + ForeignKey("distinguished_names.id"), + nullable=False, + ) expiry = Column(DateTime, default=datetime.datetime.now) - distinguished_name = relationship("DistinguishedName", lazy="joined") + distinguished_name: DistinguishedName = relationship( + "DistinguishedName", lazy="joined" + )