Skip to content

Commit

Permalink
drop pipeline_name unique constraint from user_quotas table (#165)
Browse files Browse the repository at this point in the history
Co-authored-by: Jose Soto <[email protected]>
  • Loading branch information
jsotobroad and Jose Soto authored Nov 21, 2024
1 parent 6ab1aa8 commit f42d24d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions service/src/main/resources/db/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<include file="changesets/20241030_add_pipeline_quotas.yaml" relativeToChangelogFile="true"/>
<include file="changesets/20241103_add_user_quotas.yaml" relativeToChangelogFile="true"/>
<include file="changesets/20241106_array_imputation_rename.yaml" relativeToChangelogFile="true"/>
<include file="changesets/20241121_remove_user_quota_pname_uk.yaml" relativeToChangelogFile="true"/>

<include file="changesets/20240412-testdata.yaml" relativeToChangelogFile="true"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# remove pipeline_name unique key constraint from the user_quotas table

databaseChangeLog:
- changeSet:
id: drop user quotas pipeline_name unique constraint
author: js
changes:
- dropUniqueConstraint:
tableName: user_quotas
constraintName: user_quotas_pipeline_name_key
uniqueColumns: pipeline_name
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void getOrCreateQuotaForUserAndPipeline() {
}

@Test
void addRowForNonExistentUserQuota() {
void addRowForNonExistentUserQuotaAndSecondUser() {
// assert nothing exists in the user_quotas table
assertTrue(
userQuotasRepository
Expand Down Expand Up @@ -80,6 +80,16 @@ void addRowForNonExistentUserQuota() {
userQuotasRepository
.findByUserIdAndPipelineName(TestUtils.TEST_USER_ID_1, PipelinesEnum.ARRAY_IMPUTATION)
.isPresent());

// call service with second user to test for unique constraints
quotasService.getOrCreateQuotaForUserAndPipeline(
TestUtils.TEST_USER_ID_2, PipelinesEnum.ARRAY_IMPUTATION);

// assert user + pipeline exists in the user_quotas table for the second user
assertTrue(
userQuotasRepository
.findByUserIdAndPipelineName(TestUtils.TEST_USER_ID_2, PipelinesEnum.ARRAY_IMPUTATION)
.isPresent());
}

UserQuota createAndSaveUserQuota(
Expand Down

0 comments on commit f42d24d

Please sign in to comment.