Skip to content

Commit

Permalink
Create user.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 8, 2024
1 parent 4133d7d commit c95526a
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class User(Base):
__tablename__ = 'users'

id = Column(Integer, primary_key=True)
username = Column(String(255), nullable=False, unique=True)
email = Column(String(255), nullable=False, unique=True)
password = Column(String(255), nullable=False)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

contracts = relationship('Contract', backref='user')

def __repr__(self):
return f'<User {self.username}>'

0 comments on commit c95526a

Please sign in to comment.