forum-app/backend/models.py

32 lines
766 B
Python
Raw Permalink Normal View History

2024-04-01 04:43:12 +00:00
from database import Base
2024-04-05 23:07:23 +00:00
from sqlalchemy import Column, Integer, String, ForeignKey
2024-04-01 04:43:12 +00:00
2024-04-05 23:01:15 +00:00
class Post(Base):
2024-04-01 04:43:12 +00:00
__tablename__ = 'posts'
id = Column(Integer, primary_key=True, index=True)
2024-04-01 04:43:12 +00:00
thread_id = Column(Integer, ForeignKey("threads.id"))
author = Column(String)
title = Column(String)
content = Column(String)
2024-04-05 23:01:15 +00:00
class Thread(Base):
2024-04-01 04:43:12 +00:00
__tablename__ = 'threads'
id = Column(Integer, primary_key=True, index=True)
2024-04-01 04:43:12 +00:00
author = Column(String)
title = Column(String)
2024-04-01 21:26:01 +00:00
content = Column(String)
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, index=True)
username = Column(String, unique=True)
email = Column(String, unique=True)
password = Column(String)
role = Column(String)