Skip to content

Commit

Permalink
feat: add index to default
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrinson-rise8 committed Sep 19, 2024
1 parent b4df88e commit 19c4f44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/recordlinker/linkage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ class BlockingValue(Base):
class Algorithm(Base):
__tablename__ = "algorithm"

id: orm.Mapped[int] = orm.mapped_column(primary_key=True, index=True)
is_default: orm.Mapped[bool] = orm.mapped_column(default=False)
id: orm.Mapped[int] = orm.mapped_column(primary_key=True)
is_default: orm.Mapped[bool] = orm.mapped_column(default=False, index=True)
label: orm.Mapped[str] = orm.mapped_column(String(255), unique=True)
description: orm.Mapped[str] = orm.mapped_column(Text())

def check_only_one_default(target):
"""
Check if there is already a default algorithm before inserting or updating.
If another default algorithm exists, an exception is raised to prevent the operation.
Parameters:
connection: The database connection being used for the operation.
target: The instance of the Algorithm class being inserted or updated.
Expand Down

0 comments on commit 19c4f44

Please sign in to comment.