-sharp models
class User(db.Model):
__tablename__ = "users"
id = db.Column(db.BigInteger, primary_key=True)
name = db.Column(db.VARCHAR(50), nullable=False)
email = db.Column(db.VARCHAR(200), nullable=False)
-sharp NULL
mobile = db.Column(db.VARCHAR(20), server_default=text("NULL"))
-sharp
password = db.Column(db.VARCHAR, nullable=False)
-sharp
_2fa = db.Column(db.VARCHAR(32), nullable=True)
-sharp
created_at = db.Column(db.TIMESTAMP(False), nullable=False, server_default=text("now()"))
__table_args__ = (
Index("idx_users_name", func.lower("name"), unique=True),
Index("idx_users_email", func.lower("email"), unique=True)
)
def __init__(self):
if not self.created_at:
self.created_at = now().format()
def __repr__(self):
return "<User %s>" % self.name
but there is no duplicate name and email
in the database.