19 lines
730 B
Python
19 lines
730 B
Python
"""邮箱验证码模型。"""
|
|
from sqlalchemy import Column, Integer, String, TIMESTAMP, func
|
|
from insurance.db.compat import db
|
|
|
|
|
|
class EmailVerificationCode(db.Model):
|
|
"""注册和找回密码用的邮箱验证码。"""
|
|
__tablename__ = "email_verification_codes"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
email = Column(String(255), nullable=False, index=True)
|
|
purpose = Column(String(32), nullable=False, index=True)
|
|
code_hash = Column(String(128), nullable=False)
|
|
expires_at = Column(TIMESTAMP, nullable=False)
|
|
consumed_at = Column(TIMESTAMP)
|
|
attempts = Column(Integer, default=0)
|
|
ip = Column(String(64))
|
|
created_at = Column(TIMESTAMP, server_default=func.now())
|