feat: add SQLAlchemy models for Category, CategoryWord, Game, Word

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathew Sir Guest the best
2026-05-06 22:36:35 -06:00
co-authored by Claude Opus 4.6
parent 2930adb51d
commit 041b768cd4
5 changed files with 166 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
from sqlalchemy import Column, ForeignKey, Integer, String, UniqueConstraint
from sqlalchemy.orm import relationship
from models import Base
class Category(Base):
__tablename__ = "categories"
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(50), unique=True, nullable=False)
words = relationship("CategoryWord", back_populates="category")
class CategoryWord(Base):
__tablename__ = "category_words"
__table_args__ = (UniqueConstraint("category_id", "word"),)
id = Column(Integer, primary_key=True, autoincrement=True)
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False)
word = Column(String(20), nullable=False)
category = relationship("Category", back_populates="words")