mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 06:57:47 +01:00
feat(models): change unique index
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from fastapi_users_db_sqlalchemy import GUID
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, Table
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, Table, UniqueConstraint
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.base import Base
|
||||
@@ -14,8 +14,11 @@ association_table = Table(
|
||||
|
||||
class Category(Base):
|
||||
__tablename__ = "categories"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("name", "user_id", name="uix_name_user_id"),
|
||||
)
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(length=100), unique=True, nullable=False)
|
||||
name = Column(String(length=100), nullable=False)
|
||||
description = Column(String(length=255), nullable=True)
|
||||
user_id = Column(GUID, ForeignKey("user.id"), nullable=False)
|
||||
user = relationship("User", back_populates="categories")
|
||||
|
||||
Reference in New Issue
Block a user