from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.func import now
import sqlalchemy
import uuid
from . import db


class Base(db.Model):
    id = db.Column(UUID, default=lambda: str(uuid.uuid4()), primary_key=True)
    created_at = db.Column(db.DateTime(), default=now())
    updated_at = db.Column(
        sqlalchemy.DateTime(), default=now(), onupdate=now())

    __mapper_args__ = {'order_by': sqlalchemy.desc('updated_at')}


class User(Base):
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __init__(self, username, email):
        self.username = username
        self.email = email

@@ -456,16 +456,259 @@
 (Base):%0A
+    profile = db.relationship('Profile', backref='user', lazy='dynamic',%0A                              uselist=False)%0A%0A    def __init__(self, username, email):%0A        self.username = username%0A        self.email = email%0A%0A%0Aclass Profile(Base):%0A
     user
@@ -738,16 +738,28 @@
 ing(80),
+ index=True,
  unique=
@@ -801,16 +801,28 @@
 ng(120),
+ index=True,
  unique=
@@ -826,16 +826,141 @@
 ue=True)
+%0A    display_name = db.Column(db.String(80), index=True, unique=True)%0A    user_id = db.Column(UUID, db.ForeignKey('user.id'))
 %0A%0A    de
@@ -983,32 +983,51 @@
  username, email
+, display_name=None
 ):%0A        self.
@@ -1053,28 +1053,157 @@
 %0A        self.email = email%0A
+        if not display_name:%0A            self.display_name = username%0A        else:%0A            self.display_name = display_name%0A

add Profile model