feat: add SQLAlchemy models for Category, CategoryWord, Game, Word
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2930adb51d
commit
041b768cd4
@@ -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")
|
||||
Reference in New Issue
Block a user