feat(models): add email to User and normalize UserProfile
This commit is contained in:
parent
f396c98cbe
commit
52bb003980
2 changed files with 15 additions and 15 deletions
|
|
@ -8,6 +8,7 @@ class User(db.Model):
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
username = db.Column(db.String(80), unique=True, nullable=False)
|
username = db.Column(db.String(80), unique=True, nullable=False)
|
||||||
|
email = db.Column(db.String(120), unique=True, nullable=False) # Add email field
|
||||||
_password = db.Column("password", db.String(255), nullable=False)
|
_password = db.Column("password", db.String(255), nullable=False)
|
||||||
|
|
||||||
profile = db.relationship('UserProfile', back_populates='user', uselist=False, cascade="all, delete-orphan")
|
profile = db.relationship('UserProfile', back_populates='user', uselist=False, cascade="all, delete-orphan")
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
from models import db
|
from models import db
|
||||||
|
|
||||||
class UserProfile(db.Model):
|
class UserProfile(db.Model):
|
||||||
__tablename__ = 'user_profile'
|
__tablename__ = 'user_profiles'
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
|
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
|
||||||
first_name = db.Column(db.String(80), nullable = False)
|
first_name = db.Column(db.String(50), nullable=False, default="")
|
||||||
last_name = db.Column(db.String(80), nullable = False)
|
last_name = db.Column(db.String(50), nullable=False, default="")
|
||||||
bio = db.Column(db.Text, nullable = True)
|
bio = db.Column(db.Text, default="")
|
||||||
profile_picture = db.Column(db.String(255), nullable = True)
|
profile_picture = db.Column(db.String(255), default="")
|
||||||
|
|
||||||
user = db.relationship('User', back_populates='profile')
|
user = db.relationship('User', back_populates='profile')
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue