Skip to content

Commit

Permalink
fix: fixed image constraint and adjusted test (onecx#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter authored Jun 12, 2024
1 parent 6d0a683 commit ccd486f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Getter
@Setter
@Table(name = "IMAGE", uniqueConstraints = {
@UniqueConstraint(name = "IMAGE_CONSTRAINTS", columnNames = { "REF_ID", "REF_TYPE" })
@UniqueConstraint(name = "IMAGE_CONSTRAINTS", columnNames = { "REF_ID", "TENANT_ID", "REF_TYPE" })
})
@SuppressWarnings("squid:S2160")
public class Image extends TraceableEntity {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/db/changeLog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
<include relativeToChangelogFile="true" file="v1/2024-04-23-add-slots.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-05-08-mandatory-attribute.xml"/>
<include relativeToChangelogFile="true" file="v1/2024-05-28-workspace-operator.xml"/>

<include relativeToChangelogFile="true" file="v1/2024-06-12-update-image-constraint.xml"/>
</databaseChangeLog>
12 changes: 12 additions & 0 deletions src/main/resources/db/v1/2024-06-12-update-image-constraint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">

<changeSet author="dev (generated)" id="1718199760982-1">
<dropUniqueConstraint constraintName="image_constraints" tableName="image"/>
<addUniqueConstraint columnNames="ref_id, tenant_id, ref_type" constraintName="image_constraints" tableName="image"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void uploadImage_shouldReturnBadRequest_whenImageIs() {

assertThat(exception.getErrorCode()).isEqualTo("PERSIST_ENTITY_FAILED");
assertThat(exception.getDetail()).isEqualTo(
"could not execute statement [ERROR: duplicate key value violates unique constraint 'image_constraints' Detail: Key (ref_id, ref_type)=(productNameUpload, logo) already exists.]");
"could not execute statement [ERROR: duplicate key value violates unique constraint 'image_constraints' Detail: Key (ref_id, tenant_id, ref_type)=(productNameUpload, tenant-100, logo) already exists.]");
}

@Test
Expand Down

0 comments on commit ccd486f

Please sign in to comment.