*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 07272dd1 authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Add a unique constraint for filenames per record

parent 72ac9f87
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
import dataclasses
from typing import List, Optional
from sqlalchemy import ForeignKey, create_engine
from sqlalchemy import ForeignKey, UniqueConstraint, create_engine
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column, relationship
......@@ -98,6 +98,9 @@ class Result(ModelBase):
format_id: Mapped[Optional[int]] = mapped_column(ForeignKey("format.id"))
format: Mapped[Format] = relationship(back_populates="results")
# filenames are unique per record
__table_args__ = UniqueConstraint("record", "filename")
@property
def risk(self):
"""Calculate the risk assessment for the file."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment