Skip to content

Commit

Permalink
models: restore file record key unique index
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Feb 9, 2024
1 parent d36ae9c commit 4660149
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions invenio_records_resources/records/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ def object_version(cls):
"""Object version connected to the record file."""
return db.relationship(ObjectVersion)

# NOTE: This seems to break SQLAlchemy-Continuum versioning. We should fix it
# though to make sure we don't have duplicate keys for record files.
# @declared_attr
# 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__}_record_id_key",
# "record_id",
# "key",
# unique=True,
# ),
# )
@declared_attr
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__}_record_id_key",
"record_id",
"key",
unique=True,
),
)

0 comments on commit 4660149

Please sign in to comment.