Skip to content

Commit

Permalink
models: fix record file indices
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Feb 5, 2024
1 parent 2ae2597 commit c169db5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions invenio_records_resources/records/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def record_id(cls):
UUIDType,
db.ForeignKey(cls.__record_model_cls__.id, ondelete="RESTRICT"),
nullable=False,
index=True,
)

@declared_attr
Expand All @@ -60,9 +61,10 @@ def object_version(cls):
def __table_args__(cls):
"""Table args."""
return (
# To make sure we don't have duplicate keys for record files
db.Index(
f"uidx_{cls.__tablename__}_id_key",
"id",
f"uidx_{cls.__tablename__}_record_id_key",
"record_id",
"key",
unique=True,
),
Expand Down

0 comments on commit c169db5

Please sign in to comment.