feat: Add unique constraint on sound hash and update related tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlmodel import Field, Relationship
|
||||
from sqlmodel import Field, Relationship, UniqueConstraint
|
||||
|
||||
from app.models.base import BaseModel
|
||||
|
||||
@@ -29,6 +29,11 @@ class Sound(BaseModel, table=True):
|
||||
is_music: bool = Field(default=False, nullable=False)
|
||||
is_deletable: bool = Field(default=True, nullable=False)
|
||||
|
||||
# constraints
|
||||
__table_args__ = (
|
||||
UniqueConstraint("hash", name="uq_sound_hash"),
|
||||
)
|
||||
|
||||
# relationships
|
||||
playlist_sounds: list["PlaylistSound"] = Relationship(back_populates="sound")
|
||||
extractions: list["Extraction"] = Relationship(back_populates="sound")
|
||||
|
||||
Reference in New Issue
Block a user