Skip to content

Commit

Permalink
Merge pull request #512 from bcgov/dev-marshal-DV-4299
Browse files Browse the repository at this point in the history
patroni log error - duplicate annotation key
  • Loading branch information
divyav-aot authored Oct 4, 2023
2 parents c1a4b28 + 74a7613 commit c620170
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
31 changes: 31 additions & 0 deletions api/migrations/versions/13766f2831b6_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""empty message
Revision ID: 13766f2831b6
Revises: 36e7b771fbb5
Create Date: 2023-10-03 13:53:19.344756
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "13766f2831b6"
down_revision = "36e7b771fbb5"
branch_labels = None
depends_on = None


def upgrade():
op.execute(
'ALTER TABLE public."Annotations" DROP CONSTRAINT "annotation_version_key";'
)
op.execute(
'ALTER TABLE public."Annotations" ADD CONSTRAINT annotation_version_redactionlayerid_key UNIQUE (annotationname, version, redactionlayerid);'
)


def downgrade():
op.execute(
'ALTER TABLE public."Annotations" DROP CONSTRAINT "annotation_version_redactionlayerid_key";'
)
6 changes: 5 additions & 1 deletion api/reviewer_api/models/Annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ def __newannotation(cls, annot, redactionlayerid, userinfo) -> DefaultMethodResu
]
insertstmt = insert(Annotation).values(values)
upsertstmt = insertstmt.on_conflict_do_update(
index_elements=[Annotation.annotationname, Annotation.version],
index_elements=[
Annotation.annotationname,
Annotation.version,
Annotation.redactionlayerid,
],
set_={
"isactive": False,
"updatedby": userinfo,
Expand Down

0 comments on commit c620170

Please sign in to comment.