fix: properly imports datetime, adds autoincrement

This commit is contained in:
2024-11-16 23:24:56 -03:00
parent 19f1bdd612
commit 7541548acf

View File

@@ -1,9 +1,9 @@
import datetime from datetime import datetime
from sqlalchemy.orm import mapped_column from sqlalchemy.orm import mapped_column
from app.extensions import db from app.extensions import db
class User(db.Model): class User(db.Model):
id = mapped_column(db.Integer, primary_key=True) id = mapped_column(db.Integer, primary_key=True, autoincrement=True)
username = mapped_column(db.String(255), nullable=False) username = mapped_column(db.String(255), nullable=False)
email = mapped_column(db.String(255), nullable=False) email = mapped_column(db.String(255), nullable=False)
password = mapped_column(db.String(255), nullable=False) password = mapped_column(db.String(255), nullable=False)
@@ -12,4 +12,4 @@ class User(db.Model):
birth_date = mapped_column(db.Date, nullable=False) birth_date = mapped_column(db.Date, nullable=False)
address = mapped_column(db.String(255), nullable=False) address = mapped_column(db.String(255), nullable=False)
phone_number = mapped_column(db.String(255), nullable=False) phone_number = mapped_column(db.String(255), nullable=False)
registration_date = mapped_column(db.DateTime, default=datetime.datetime.utcnow, nullable=False) registration_date = mapped_column(db.DateTime, default=datetime.utcnow, nullable=False)