Skip to content

Commit

Permalink
Create models.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Sep 22, 2024
1 parent dc04237 commit e17d0f4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bank_integration/banks/banking_app/app/database/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base

BaseModel = declarative_base()

class User(BaseModel):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
username = Column(String(50), unique=True, nullable=False)
email = Column(String(120), unique=True, nullable=False)
password = Column(String(128), nullable=False)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

class Post(BaseModel):
__tablename__ = "posts"
id = Column(Integer, primary_key=True)
title = Column(String(100), nullable=False)
content = Column(String, nullable=False)
user_id = Column(Integer, ForeignKey("users.id"))
user = relationship("User", backref="posts")
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

0 comments on commit e17d0f4

Please sign in to comment.