diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerIT.java b/src/integrationTest/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerIT.java index 9b99b1bf01..d6841d9239 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerIT.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerIT.java @@ -80,7 +80,7 @@ void setUp() { EmailNotificationResponse mockResponse = new EmailNotificationResponse(); mockResponse.setTaskId("task-123"); mockResponse.setStatus(SCHEDULED_STATUS); - mockResponse.setNotificationId(UUID.randomUUID()); + mockResponse.setNotificationId(1); when(notificationService.scheduleEmailNotification( any(EmailNotificationRequest.class), @@ -107,21 +107,21 @@ void shouldSendAllDefendantResponseEmailsSuccessfully() throws Exception { pcsCase.setCaseReference(1234567890L); PaymentAgreementEntity paymentAgreement = new PaymentAgreementEntity(); - paymentAgreement.setId(UUID.randomUUID()); + paymentAgreement.setId(1); DefendantResponseEntity defendantResponse = new DefendantResponseEntity(); defendantResponse.setParty(party); defendantResponse.setPcsCase(pcsCase); defendantResponse.setPaymentAgreement(paymentAgreement); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; when(defendantResponseRepository.findById(defendantResponseId)) .thenReturn(Optional.of(defendantResponse)); EmailNotificationResponse response = new EmailNotificationResponse(); response.setTaskId("task-123"); response.setStatus(SCHEDULED_STATUS); - response.setNotificationId(UUID.randomUUID()); + response.setNotificationId(1); when(notificationService.sendDefendantResponseNoCounterclaimEmailNotification(defendantResponse)) .thenReturn(response); @@ -147,7 +147,7 @@ void shouldSendAllDefendantResponseEmailsSuccessfully() throws Exception { @Test @DisplayName("Should return 404 when defendant response not found") void shouldReturn404WhenDefendantResponseNotFound() throws Exception { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; when(defendantResponseRepository.findById(defendantResponseId)) .thenReturn(Optional.empty()); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AddressEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AddressEntity.java index f3bb8940de..bf99bcf41d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AddressEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AddressEntity.java @@ -11,7 +11,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.UUID; @Entity @Getter @@ -23,8 +22,8 @@ public class AddressEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; private String addressLine1; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AsbProhibitedConductEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AsbProhibitedConductEntity.java index 0d8189564d..c7c6c1ec24 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AsbProhibitedConductEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/AsbProhibitedConductEntity.java @@ -18,7 +18,6 @@ import org.hibernate.type.SqlTypes; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import java.util.UUID; @Builder @Getter @@ -30,8 +29,8 @@ public class AsbProhibitedConductEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JsonBackReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseLinkEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseLinkEntity.java index a00ae4f4ae..3ed1520ab8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseLinkEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseLinkEntity.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.UUID; @Entity @Table(name = "case_link") @@ -31,8 +30,8 @@ public class CaseLinkEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "case_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseNoteEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseNoteEntity.java index 3a4188735a..1af6c62136 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseNoteEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/CaseNoteEntity.java @@ -18,7 +18,6 @@ import java.time.Instant; import java.time.LocalDateTime; -import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; import static uk.gov.hmcts.reform.pcs.config.ClockConfiguration.UK_ZONE_ID; @@ -33,8 +32,8 @@ public class CaseNoteEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = LAZY) @JoinColumn(name = "case_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimActivityLogEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimActivityLogEntity.java index 69d1127229..56f5f5857f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimActivityLogEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimActivityLogEntity.java @@ -23,7 +23,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import java.time.LocalDateTime; -import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; @@ -37,8 +36,8 @@ public class ClaimActivityLogEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = LAZY) @JoinColumn(name = "case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/DraftCaseDataEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/DraftCaseDataEntity.java index 00f4de7b64..4b5ab0c240 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/DraftCaseDataEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/DraftCaseDataEntity.java @@ -26,8 +26,8 @@ public class DraftCaseDataEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; private Long caseReference; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/HelpWithFeesEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/HelpWithFeesEntity.java index d3b1fd33cb..9644e85dfb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/HelpWithFeesEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/HelpWithFeesEntity.java @@ -12,7 +12,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.UUID; @Entity @Builder @@ -24,8 +23,8 @@ public class HelpWithFeesEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @Column(name = "hwf_reference", nullable = false) private String hwfReference; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PartyAccessCodeEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PartyAccessCodeEntity.java index d70f1e3171..3a66e04bfc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PartyAccessCodeEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PartyAccessCodeEntity.java @@ -33,8 +33,8 @@ public class PartyAccessCodeEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; private UUID partyId; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/TenancyLicenceEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/TenancyLicenceEntity.java index 62af900a1b..61e2cc3907 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/TenancyLicenceEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/TenancyLicenceEntity.java @@ -23,7 +23,6 @@ import java.math.BigDecimal; import java.time.LocalDate; -import java.util.UUID; @Entity @Builder @@ -35,8 +34,8 @@ public class TenancyLicenceEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JoinColumn(name = "case_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/NoticeOfPossessionEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/NoticeOfPossessionEntity.java index 29eec0d46b..b2650e72d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/NoticeOfPossessionEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/NoticeOfPossessionEntity.java @@ -22,7 +22,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.UUID; @Entity @Builder @@ -34,8 +33,8 @@ public class NoticeOfPossessionEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JsonBackReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/PossessionAlternativesEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/PossessionAlternativesEntity.java index 331cfda629..b649e0abd6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/PossessionAlternativesEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/PossessionAlternativesEntity.java @@ -22,7 +22,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyHousingAct; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; -import java.util.UUID; @Entity @Builder @@ -34,8 +33,8 @@ public class PossessionAlternativesEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JsonBackReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/RentArrearsEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/RentArrearsEntity.java index 201568b018..c9e0560568 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/RentArrearsEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/RentArrearsEntity.java @@ -20,7 +20,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import java.math.BigDecimal; -import java.util.UUID; @Entity @Builder @@ -32,8 +31,8 @@ public class RentArrearsEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JsonBackReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/StatementOfTruthEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/StatementOfTruthEntity.java index 6c5ea4cf7c..8e7d44c9bf 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/StatementOfTruthEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/claim/StatementOfTruthEntity.java @@ -24,7 +24,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.respondpossessionclaim.DefendantResponseEntity; import java.time.LocalDateTime; -import java.util.UUID; @Entity @Builder @@ -36,8 +35,8 @@ public class StatementOfTruthEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JsonBackReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/RiskProfileEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/RiskProfileEntity.java index 13901ae837..93fdd4d1fc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/RiskProfileEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/RiskProfileEntity.java @@ -17,7 +17,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.YesNoNotSure; import uk.gov.hmcts.reform.pcs.ccd.domain.enforcetheorder.common.VulnerableCategory; -import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; @@ -28,8 +27,8 @@ public class RiskProfileEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne(fetch = LAZY) @JoinColumn(name = "enf_case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/SelectedDefendantEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/SelectedDefendantEntity.java index 3eb337fd38..ba7dcf8ab1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/SelectedDefendantEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/SelectedDefendantEntity.java @@ -16,7 +16,6 @@ import lombok.Setter; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; -import java.util.UUID; @Entity @Table(name = "enf_selected_defendants") @@ -28,8 +27,8 @@ public class SelectedDefendantEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "enf_case_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantEntity.java index a7421ec9f3..9c0ac3b293 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantEntity.java @@ -25,7 +25,6 @@ import java.math.BigDecimal; import java.time.Instant; -import java.util.UUID; @Entity @Builder @@ -37,8 +36,8 @@ public class WarrantEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JoinColumn(name = "enf_case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantOfRestitutionEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantOfRestitutionEntity.java index ca47e4d765..37f1f13fcf 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantOfRestitutionEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WarrantOfRestitutionEntity.java @@ -23,7 +23,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import java.time.Instant; -import java.util.UUID; @Entity @Builder @@ -35,8 +34,8 @@ public class WarrantOfRestitutionEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JoinColumn(name = "enf_case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritEntity.java index 3823c2a689..9496b8dc74 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritEntity.java @@ -22,7 +22,6 @@ import java.math.BigDecimal; import java.time.Instant; -import java.util.UUID; @Entity @Table(name = "enf_writ") @@ -31,8 +30,8 @@ public class WritEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne @JoinColumn(name = "enf_case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritOfRestitutionEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritOfRestitutionEntity.java index b5d4f64327..8b1b2fa697 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritOfRestitutionEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/WritOfRestitutionEntity.java @@ -21,7 +21,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.LanguageUsed; import java.time.Instant; -import java.util.UUID; @Entity @Table(name = "enf_writ_of_restitution") @@ -33,8 +32,8 @@ public class WritOfRestitutionEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "enf_case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/feesandpay/FeePaymentEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/feesandpay/FeePaymentEntity.java index d7d0bc0c07..dbdad78bdd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/feesandpay/FeePaymentEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/feesandpay/FeePaymentEntity.java @@ -45,8 +45,8 @@ public class FeePaymentEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = LAZY) @JoinColumn(name = "possession_claim_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/party/ContactPreferencesEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/party/ContactPreferencesEntity.java index 474098ee52..7fe145f5c0 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/party/ContactPreferencesEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/party/ContactPreferencesEntity.java @@ -16,7 +16,6 @@ import org.hibernate.type.SqlTypes; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import java.util.UUID; @Entity @Builder @@ -28,8 +27,8 @@ public class ContactPreferencesEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @Enumerated(EnumType.STRING) @JdbcTypeCode(SqlTypes.NAMED_ENUM) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/CounterClaimPartyEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/CounterClaimPartyEntity.java index 409c478b35..120ae8ddd2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/CounterClaimPartyEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/CounterClaimPartyEntity.java @@ -15,7 +15,6 @@ import lombok.Setter; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; -import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; @@ -29,8 +28,8 @@ public class CounterClaimPartyEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = LAZY) @JoinColumn(name = "cc_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/DefendantResponseEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/DefendantResponseEntity.java index b5473aabca..1704b3f463 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/DefendantResponseEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/DefendantResponseEntity.java @@ -38,7 +38,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.UUID; import static jakarta.persistence.CascadeType.ALL; @@ -53,8 +52,8 @@ public class DefendantResponseEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "claim_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/HouseholdCircumstancesEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/HouseholdCircumstancesEntity.java index f2f58e0efa..ed7699ae36 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/HouseholdCircumstancesEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/HouseholdCircumstancesEntity.java @@ -29,7 +29,6 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import java.util.UUID; import static jakarta.persistence.CascadeType.ALL; @@ -43,8 +42,8 @@ public class HouseholdCircumstancesEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "defendant_response_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PartyAttributeAssertationEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PartyAttributeAssertationEntity.java index 81451bf45a..ea4751368b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PartyAttributeAssertationEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PartyAttributeAssertationEntity.java @@ -35,8 +35,8 @@ public class PartyAttributeAssertationEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "party_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PaymentAgreementEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PaymentAgreementEntity.java index c069771583..45c2fb232c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PaymentAgreementEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/PaymentAgreementEntity.java @@ -22,7 +22,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.YesNoNotSure; import java.math.BigDecimal; -import java.util.UUID; @Entity @Table(name = "payment_agreement") @@ -34,8 +33,8 @@ public class PaymentAgreementEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "defendant_response_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/ReasonableAdjustmentEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/ReasonableAdjustmentEntity.java index d5d69e65aa..c8357873ae 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/ReasonableAdjustmentEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/ReasonableAdjustmentEntity.java @@ -21,7 +21,6 @@ import org.hibernate.type.SqlTypes; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import java.util.UUID; @Entity @Table(name = "reasonable_adjustments") @@ -33,8 +32,8 @@ public class ReasonableAdjustmentEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "defendant_response_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularExpenseEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularExpenseEntity.java index 4ede1d8628..a76fe8c868 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularExpenseEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularExpenseEntity.java @@ -19,7 +19,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.RegularExpenseType; import java.math.BigDecimal; -import java.util.UUID; @Entity @Table(name = "regular_expenses") @@ -31,8 +30,8 @@ public class RegularExpenseEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne @JoinColumn(name = "hc_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeEntity.java index 54d0ebf659..ddd95b3da7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeEntity.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.UUID; import static jakarta.persistence.CascadeType.ALL; import static jakarta.persistence.FetchType.LAZY; @@ -33,8 +32,8 @@ public class RegularIncomeEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @OneToOne(fetch = LAZY) @JoinColumn(name = "hc_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeItemEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeItemEntity.java index cb5d4d4e9b..283b8c7837 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeItemEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/respondpossessionclaim/RegularIncomeItemEntity.java @@ -21,7 +21,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.RecurrenceFrequency; import java.math.BigDecimal; -import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; @@ -35,8 +34,8 @@ public class RegularIncomeItemEntity { @Id - @GeneratedValue(strategy = GenerationType.UUID) - private UUID id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; @ManyToOne(fetch = LAZY) @JoinColumn(name = "regular_income_id") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefenceFormTaskData.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefenceFormTaskData.java index 241cd45d55..c9a58547b6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefenceFormTaskData.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefenceFormTaskData.java @@ -17,7 +17,7 @@ public class DefenceFormTaskData { private final String caseReference; - private final UUID defendantResponseId; + private final Integer defendantResponseId; private final UUID defendantPartyId; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefendantResponseStatusChangeTaskData.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefendantResponseStatusChangeTaskData.java index 775ae6caeb..02bb7576b8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefendantResponseStatusChangeTaskData.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/DefendantResponseStatusChangeTaskData.java @@ -7,7 +7,6 @@ import java.io.Serial; import java.io.Serializable; -import java.util.UUID; @Data @Builder @@ -16,5 +15,5 @@ public class DefendantResponseStatusChangeTaskData implements Serializable { @Serial private static final long serialVersionUID = 1L; - private UUID defendantResponseId; + private Integer defendantResponseId; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/FeePaymentStatusChangeTaskData.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/FeePaymentStatusChangeTaskData.java index c938f69397..93ced4589f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/FeePaymentStatusChangeTaskData.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/model/FeePaymentStatusChangeTaskData.java @@ -7,7 +7,6 @@ import java.io.Serial; import java.io.Serializable; -import java.util.UUID; @Data @Builder @@ -16,5 +15,5 @@ public class FeePaymentStatusChangeTaskData implements Serializable { @Serial private static final long serialVersionUID = 1L; - private UUID feePaymentId; + private Integer feePaymentId; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/ClaimActivityLogRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/ClaimActivityLogRepository.java index e0e6c8ce84..49f02b367e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/ClaimActivityLogRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/ClaimActivityLogRepository.java @@ -13,7 +13,7 @@ import java.util.UUID; @Repository -public interface ClaimActivityLogRepository extends JpaRepository { +public interface ClaimActivityLogRepository extends JpaRepository { List findAllByPcsCase_Id(UUID caseId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DefendantResponseRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DefendantResponseRepository.java index 43426bd63e..459796d1fd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DefendantResponseRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DefendantResponseRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; @Repository -public interface DefendantResponseRepository extends JpaRepository { +public interface DefendantResponseRepository extends JpaRepository { boolean existsByClaimPcsCaseCaseReferenceAndPartyId(Long caseReference, UUID partyId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DraftCaseDataRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DraftCaseDataRepository.java index 354ac1830e..57aff706fd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DraftCaseDataRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/DraftCaseDataRepository.java @@ -7,7 +7,7 @@ import java.util.Optional; import java.util.UUID; -public interface DraftCaseDataRepository extends JpaRepository { +public interface DraftCaseDataRepository extends JpaRepository { Optional findByCaseReferenceAndEventIdAndIdamUserId( long caseReference, EventId eventId, UUID idamUserId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAccessCodeRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAccessCodeRepository.java index 5836ce07b0..61fb2ac8c2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAccessCodeRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAccessCodeRepository.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.UUID; -public interface PartyAccessCodeRepository extends JpaRepository { +public interface PartyAccessCodeRepository extends JpaRepository { List findAllByPcsCase_Id(UUID pcsCaseId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAttributeAssertionRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAttributeAssertionRepository.java index 9bc36243b4..a426968358 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAttributeAssertionRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/PartyAttributeAssertionRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; @Repository -public interface PartyAttributeAssertionRepository extends JpaRepository { +public interface PartyAttributeAssertionRepository extends JpaRepository { List findByPartyIdAndAssertedByAndStatus( UUID partyId, PartyAttributeAssertedBy assertedBy, PartyAttributeAssertionStatus status); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/RiskProfileRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/RiskProfileRepository.java index 308890d69f..97d6a402c3 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/RiskProfileRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/RiskProfileRepository.java @@ -3,8 +3,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.RiskProfileEntity; -import java.util.UUID; public interface RiskProfileRepository - extends JpaRepository { + extends JpaRepository { } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/SelectedDefendantRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/SelectedDefendantRepository.java index 26f8d994cd..ba9db14c3a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/SelectedDefendantRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/SelectedDefendantRepository.java @@ -4,9 +4,8 @@ import org.springframework.stereotype.Repository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.SelectedDefendantEntity; -import java.util.UUID; @Repository -public interface SelectedDefendantRepository extends JpaRepository { +public interface SelectedDefendantRepository extends JpaRepository { } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantOfRestitutionRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantOfRestitutionRepository.java index 84b6e22dcf..86993e4055 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantOfRestitutionRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantOfRestitutionRepository.java @@ -3,7 +3,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.WarrantOfRestitutionEntity; -import java.util.UUID; -public interface WarrantOfRestitutionRepository extends JpaRepository { +public interface WarrantOfRestitutionRepository extends JpaRepository { } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantRepository.java index 3c0e457192..a7f202699e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WarrantRepository.java @@ -3,7 +3,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.WarrantEntity; -import java.util.UUID; -public interface WarrantRepository extends JpaRepository { +public interface WarrantRepository extends JpaRepository { } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritOfRestitutionRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritOfRestitutionRepository.java index e18f8e7cc9..90d54ee254 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritOfRestitutionRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritOfRestitutionRepository.java @@ -4,9 +4,8 @@ import org.springframework.stereotype.Repository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.WritOfRestitutionEntity; -import java.util.UUID; @Repository public interface WritOfRestitutionRepository extends - JpaRepository { + JpaRepository { } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritRepository.java index a310b7a0d5..1e60795e91 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/WritRepository.java @@ -3,7 +3,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.WritEntity; -import java.util.UUID; -public interface WritRepository extends JpaRepository { +public interface WritRepository extends JpaRepository { } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/feeandpay/FeePaymentRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/feeandpay/FeePaymentRepository.java index 014ab66038..6693ad2b1d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/feeandpay/FeePaymentRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/feeandpay/FeePaymentRepository.java @@ -6,7 +6,7 @@ import java.util.Optional; import java.util.UUID; -public interface FeePaymentRepository extends JpaRepository { +public interface FeePaymentRepository extends JpaRepository { Optional findByServiceRequestReference(String serviceRequestReference); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceService.java index 652b586ae0..492d219170 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceService.java @@ -45,7 +45,7 @@ public DefenceFormPersistenceService(DefendantResponseRepository defendantRespon } @Transactional(readOnly = true) - public Optional buildContextIfNotAttached(UUID defendantResponseId) { + public Optional buildContextIfNotAttached(Integer defendantResponseId) { DefendantResponseEntity response = loadResponse(defendantResponseId); if (response.getSubmissionDocument() != null) { return Optional.empty(); @@ -55,7 +55,7 @@ public Optional buildContextIfNotAttached(UUID defenda } @Transactional - public void attach(UUID defendantResponseId, String dmStoreUrl) { + public void attach(Integer defendantResponseId, String dmStoreUrl) { DefendantResponseEntity response = loadResponse(defendantResponseId); if (response.getSubmissionDocument() != null) { return; @@ -71,7 +71,7 @@ public void attach(UUID defendantResponseId, String dmStoreUrl) { claimActivityLogService.logGenerationSuccess(pcsCase, response.getParty()); } - private DefendantResponseEntity loadResponse(UUID defendantResponseId) { + private DefendantResponseEntity loadResponse(Integer defendantResponseId) { return defendantResponseRepository.findById(defendantResponseId) .orElseThrow(() -> new IllegalStateException( "No defendant response found for id: " + defendantResponseId)); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormScheduler.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormScheduler.java index dc50e47582..3d5af955fc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormScheduler.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormScheduler.java @@ -24,7 +24,7 @@ public DefenceFormScheduler(SchedulerClient schedulerClient) { this.schedulerClient = schedulerClient; } - public void scheduleDefenceFormGeneration(long caseReference, UUID defendantResponseId, UUID defendantPartyId) { + public void scheduleDefenceFormGeneration(long caseReference, Integer defendantResponseId, UUID defendantPartyId) { DefenceFormTaskData taskData = DefenceFormTaskData.builder() .caseReference(String.valueOf(caseReference)) .defendantResponseId(defendantResponseId) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormService.java index f4233f48ba..a397b3b72c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormService.java @@ -5,7 +5,6 @@ import uk.gov.hmcts.reform.pcs.ccd.service.document.DocumentImportService; import java.util.Optional; -import java.util.UUID; /** * Generates the defence form and attaches it to the case, where it shows under "Statements of case". @@ -31,7 +30,7 @@ public DefenceFormService(DefenceFormPersistenceService persistenceService, this.documentImportService = documentImportService; } - public void generateAndAttach(UUID defendantResponseId) { + public void generateAndAttach(Integer defendantResponseId) { Optional context = persistenceService.buildContextIfNotAttached(defendantResponseId); if (context.isEmpty()) { @@ -48,7 +47,7 @@ public void generateAndAttach(UUID defendantResponseId) { } } - private void deleteOrphanedDocument(UUID defendantResponseId, String dmStoreUrl) { + private void deleteOrphanedDocument(Integer defendantResponseId, String dmStoreUrl) { try { documentImportService.deleteDocument(dmStoreUrl); } catch (Exception e) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/respondpossessionclaim/DefendantResponseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/respondpossessionclaim/DefendantResponseService.java index db9a0c23ce..16d24dab4a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/respondpossessionclaim/DefendantResponseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/respondpossessionclaim/DefendantResponseService.java @@ -130,7 +130,7 @@ public void saveDefendantResponse(long caseReference, ); // Citizen path only. Schedule after commit so generation can't run against a rolled-back response. - UUID defendantResponseId = savedResponse.getId(); + Integer defendantResponseId = savedResponse.getId(); UUID defendantPartyId = savedResponse.getParty().getId(); scheduleAfterCommit(() -> defenceFormScheduler.scheduleDefenceFormGeneration( caseReference, defendantResponseId, defendantPartyId)); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponent.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponent.java index 64cabe5204..3a16a43d22 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponent.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponent.java @@ -13,7 +13,6 @@ import uk.gov.hmcts.reform.pcs.notify.service.DefendantResponseNotificationService; import java.time.Duration; -import java.util.UUID; @Slf4j @Component @@ -48,7 +47,7 @@ public CustomTask defendantResponseSubmit )) .execute((taskInstance, executionContext) -> { DefendantResponseStatusChangeTaskData taskData = taskInstance.getData(); - UUID defendantResponseId = taskData.getDefendantResponseId(); + Integer defendantResponseId = taskData.getDefendantResponseId(); log.info("Processing defendant response submitted notification for: {}", defendantResponseId); defendantResponseNotificationService.sendEmailNotificationForNoCounterClaim(defendantResponseId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponent.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponent.java index 42fb648acb..aad1c58658 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponent.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponent.java @@ -13,7 +13,6 @@ import uk.gov.hmcts.reform.pcs.notify.service.FeePaymentNotificationService; import java.time.Duration; -import java.util.UUID; @Slf4j @Component @@ -47,7 +46,7 @@ public CustomTask feePaymentPaidNotificationTask )) .execute((taskInstance, executionContext) -> { FeePaymentStatusChangeTaskData taskData = taskInstance.getData(); - UUID feePaymentId = taskData.getFeePaymentId(); + Integer feePaymentId = taskData.getFeePaymentId(); log.info("Processing fee payment paid notification for: {}", feePaymentId); feePaymentNotificationService.sendClaimantPaidCaseIssuedNotification(feePaymentId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/entities/CaseNotification.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/entities/CaseNotification.java index 3c496a7ecb..1ad6b89b3b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/entities/CaseNotification.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/entities/CaseNotification.java @@ -40,9 +40,9 @@ public class CaseNotification { @Id - @GeneratedValue(strategy = GenerationType.UUID) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) - private UUID id; + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "case_id", nullable = false) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListener.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListener.java index 59ce58228d..e0289fe057 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListener.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListener.java @@ -47,7 +47,7 @@ public void onPostUpdate(DefendantResponseEntity entity) { private void scheduleDefendantResponseSubmittedNotification(DefendantResponseEntity defendantResponse) { String taskId = UUID.randomUUID().toString(); - UUID defendantResponseId = defendantResponse.getId(); + Integer defendantResponseId = defendantResponse.getId(); log.info("Scheduling defendant response submitted notification for: {}, with task id: {}", defendantResponseId, taskId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListener.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListener.java index 872b6a3d05..eb8191bc4e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListener.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListener.java @@ -42,7 +42,7 @@ public void onPostUpdate(FeePaymentEntity entity) { } String taskId = UUID.randomUUID().toString(); - UUID feePaymentId = entity.getId(); + Integer feePaymentId = entity.getId(); log.info("Scheduling fee payment paid notification for: {}, with task id: {}", feePaymentId, taskId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/EmailNotificationResponse.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/EmailNotificationResponse.java index 8b7a3666ec..79a3119d49 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/EmailNotificationResponse.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/EmailNotificationResponse.java @@ -2,11 +2,9 @@ import lombok.Data; -import java.util.UUID; - @Data public class EmailNotificationResponse { private String taskId; private String status; - private UUID notificationId; // Database notification record ID + private Integer notificationId; // Database notification record ID } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/SendEmailTaskData.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/SendEmailTaskData.java index c06557dbc1..32b9d34fbb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/SendEmailTaskData.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/model/SendEmailTaskData.java @@ -5,7 +5,6 @@ import lombok.Data; import java.util.Map; -import java.util.UUID; @Data @Builder(toBuilder = true) @@ -19,6 +18,6 @@ public class SendEmailTaskData { private final String reference; private final String emailReplyToId; private final String notificationId; // GOV.UK Notify notification ID (set after sending) - private final UUID dbNotificationId; // Database notification record ID (set before sending) + private final Integer dbNotificationId; // Database notification record ID (set before sending) } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/repository/NotificationRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/repository/NotificationRepository.java index 98ea0a712a..fe92f626ac 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/repository/NotificationRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/repository/NotificationRepository.java @@ -6,7 +6,7 @@ import java.util.Optional; import java.util.UUID; -public interface NotificationRepository extends JpaRepository { +public interface NotificationRepository extends JpaRepository { /** * Find a case notification by its provider notification ID. * diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationService.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationService.java index bc1609c600..4e557c194c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationService.java @@ -22,7 +22,7 @@ public class DefendantResponseNotificationService { private final CounterClaimRepository counterClaimRepository; @Transactional - public void sendDefendantResponseReceived(UUID defendantResponseId) { + public void sendDefendantResponseReceived(Integer defendantResponseId) { DefendantResponseEntity defendantResponse = defendantResponseRepository.findById(defendantResponseId) .orElseThrow(() -> new IllegalArgumentException("Defendant response not found: " + defendantResponseId)); @@ -30,7 +30,7 @@ public void sendDefendantResponseReceived(UUID defendantResponseId) { } @Transactional - public void sendEmailNotificationForNoCounterClaim(UUID defendantResponseId) { + public void sendEmailNotificationForNoCounterClaim(Integer defendantResponseId) { DefendantResponseEntity defendantResponse = defendantResponseRepository.findById(defendantResponseId) .orElseThrow(() -> new IllegalArgumentException("Defendant response not found: " + defendantResponseId)); @@ -44,7 +44,7 @@ public void sendEmailNotificationForNoCounterClaim(UUID defendantResponseId) { } @Transactional - public void sendDefendantEmailNotificationForCounterclaim(UUID defendantResponseId) { + public void sendDefendantEmailNotificationForCounterclaim(Integer defendantResponseId) { DefendantResponseEntity defendantResponse = defendantResponseRepository.findById(defendantResponseId) .orElseThrow(() -> new IllegalArgumentException("Defendant response not found: " + defendantResponseId)); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationService.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationService.java index 7f2c56d27f..1a6e266139 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationService.java @@ -8,8 +8,6 @@ import uk.gov.hmcts.reform.pcs.ccd.repository.feeandpay.FeePaymentRepository; import uk.gov.hmcts.reform.pcs.exception.FeePaymentNotFoundException; -import java.util.UUID; - @Slf4j @Service @RequiredArgsConstructor @@ -19,7 +17,7 @@ public class FeePaymentNotificationService { private final FeePaymentRepository feePaymentRepository; @Transactional - public void sendClaimantPaidCaseIssuedNotification(UUID feePaymentId) { + public void sendClaimantPaidCaseIssuedNotification(Integer feePaymentId) { FeePaymentEntity feePayment = feePaymentRepository.findById(feePaymentId) .orElseThrow(() -> new FeePaymentNotFoundException("Fee payment not found: " + feePaymentId)); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationService.java b/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationService.java index cf73ba2e97..dfd24b99a9 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationService.java @@ -239,7 +239,7 @@ public EmailNotificationResponse scheduleEmailNotification( * @param dbNotificationId the unique identifier of the notification stored in the database * @param providerNotificationId the unique identifier of the notification assigned by the provider */ - public void updateNotificationAfterSending(UUID dbNotificationId, UUID providerNotificationId) { + public void updateNotificationAfterSending(Integer dbNotificationId, UUID providerNotificationId) { Optional notificationOpt = notificationRepository.findById(dbNotificationId); if (notificationOpt.isEmpty()) { log.error("Notification not found with ID: {}", dbNotificationId); @@ -257,7 +257,7 @@ public void updateNotificationAfterSending(UUID dbNotificationId, UUID providerN * @param dbNotificationId the unique identifier of the notification in the database * @param exception the exception containing the details of the failure */ - public void updateNotificationAfterFailure(UUID dbNotificationId, Exception exception) { + public void updateNotificationAfterFailure(Integer dbNotificationId, Exception exception) { Optional notificationOpt = notificationRepository.findById(dbNotificationId); if (notificationOpt.isEmpty()) { log.error("Notification not found with ID on failure: {}", dbNotificationId); @@ -325,7 +325,7 @@ private CaseNotification createCaseNotification( * @param dbNotificationId the unique identifier of the notification in the database * @param statusString the new status to set for the notification, represented as a string */ - public void updateNotificationStatus(UUID dbNotificationId, String statusString) { + public void updateNotificationStatus(Integer dbNotificationId, String statusString) { Optional notificationOpt = notificationRepository.findById(dbNotificationId); if (notificationOpt.isEmpty()) { log.error("Notification not found with ID on status update: {}", dbNotificationId); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyController.java b/src/main/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyController.java index fe37d0a604..076d63b4c6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyController.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyController.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Optional; -import java.util.UUID; import static org.springframework.http.HttpHeaders.AUTHORIZATION; @@ -42,7 +41,7 @@ public NotifyController(NotificationService notificationService, public ResponseEntity> sendDefendantResponseEmails( @RequestHeader(value = AUTHORIZATION, defaultValue = "DummyId") String authorisation, @RequestHeader(value = "ServiceAuthorization") String serviceAuthorization, - @RequestParam UUID defendantResponseId) { + @RequestParam Integer defendantResponseId) { log.info("Received request to send all defendant response emails for {}", defendantResponseId); // temporary endpoint to test sending emails diff --git a/src/main/resources/db/migration/R__postcode_court_triggers.sql b/src/main/resources/db/migration/R__postcode_court_triggers.sql deleted file mode 100644 index 45352d6f0a..0000000000 --- a/src/main/resources/db/migration/R__postcode_court_triggers.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* - Trigger and function to clean up postcode values to have no spaces and be all in upper case -*/ -CREATE OR REPLACE FUNCTION postcode_court_mapping_trigger_func() - RETURNS trigger - LANGUAGE plpgsql -AS $func$ -BEGIN - NEW.postcode = upper(regexp_replace(NEW.postcode, '\s', '', 'g')); - RETURN NEW; -END; -$func$; - -CREATE OR REPLACE TRIGGER postcode_court_mapping_trigger - BEFORE INSERT OR UPDATE ON postcode_court_mapping - FOR EACH ROW EXECUTE FUNCTION postcode_court_mapping_trigger_func(); diff --git a/src/main/resources/db/migration/V001__postcode_court.sql b/src/main/resources/db/migration/V001__postcode_court.sql deleted file mode 100644 index b67072754e..0000000000 --- a/src/main/resources/db/migration/V001__postcode_court.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE postcode_court_mapping ( - postcode VARCHAR(20) NOT NULL, - epimid INT NOT NULL, - legislative_country VARCHAR(80) NOT NULL, - effective_from TIMESTAMP, - effective_to TIMESTAMP, - audit JSONB NOT NULL, - PRIMARY KEY (postcode, epimid) -); - -CREATE INDEX idx_postcode ON postcode_court_mapping(postcode); diff --git a/src/main/resources/db/migration/V001__r1a_baseline_schema.sql b/src/main/resources/db/migration/V001__r1a_baseline_schema.sql new file mode 100644 index 0000000000..9de379ebbc --- /dev/null +++ b/src/main/resources/db/migration/V001__r1a_baseline_schema.sql @@ -0,0 +1,1870 @@ +-- V001__r1a_baseline_schema.sql +-- HDPI-7834: R1A consolidated baseline schema with integer (int4 identity) internal primary keys. +-- Source: live AAT schema (canonical), + reconciled fk_fee_payment_claim (AAT-only drift), + UUID->integer +-- conversion of 31 internal tables. Retained UUID: pcs_case, party, claim, counter_claim, +-- general_application, enf_case, document, claim_ground, case_flag, case_party_flag, case_link_reason, +-- flag_ref_data, legal_representative. Replaces the incremental V001-V135. Pre-go-live: no data preserved. + + + + + +CREATE SCHEMA draft; + + + + + + +CREATE TYPE public.contact_preference_type AS ENUM ( + 'EMAIL', + 'POST' +); + + + +CREATE TYPE public.income_type AS ENUM ( + 'INCOME_FROM_JOBS', + 'PENSION', + 'UNIVERSAL_CREDIT', + 'OTHER_BENEFITS', + 'MONEY_FROM_ELSEWHERE' +); + + + +CREATE TYPE public.party_attribute_assertion_status AS ENUM ( + 'SUBMITTED', + 'UNDER_REVIEW', + 'ACCEPTED', + 'REJECTED' +); + + + +CREATE TYPE public.party_attribute_assertion_submitted_by AS ENUM ( + 'CLAIMANT', + 'DEFENDANT', + 'JUDGE', + 'COURT_STAFF', + 'CASE_WORKER' +); + + + +CREATE TYPE public.recurrence_frequency AS ENUM ( + 'WEEKLY', + 'MONTHLY' +); + + + +CREATE TYPE public.statement_of_truth_completed_by AS ENUM ( + 'CLAIMANT', + 'LEGAL_REPRESENTATIVE' +); + + + +CREATE TYPE public.yes_no AS ENUM ( + 'YES', + 'NO' +); + + + +CREATE TYPE public.yes_no_na AS ENUM ( + 'YES', + 'NO', + 'NOT_APPLICABLE' +); + + + +CREATE TYPE public.yes_no_not_sure AS ENUM ( + 'YES', + 'NO', + 'NOT_SURE' +); + + + +CREATE TYPE public.yes_no_prefer_not_to_say AS ENUM ( + 'YES', + 'NO', + 'PREFER_NOT_TO_SAY' +); + + + +CREATE FUNCTION public.postcode_court_mapping_trigger_func() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + NEW.postcode = upper(regexp_replace(NEW.postcode, '\s', '', 'g')); + RETURN NEW; +END; +$$; + + + + + +CREATE TABLE draft.draft_case_data ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + case_reference bigint NOT NULL, + case_data jsonb, + event_id varchar(70) NOT NULL, + idam_user_id uuid NOT NULL, + party_id uuid +); + + + +CREATE TABLE public.address ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + address_line1 varchar(100), + address_line2 varchar(100), + address_line3 varchar(100), + post_town varchar(100), + county varchar(100), + postcode varchar(14), + country varchar(100) +); + + + +CREATE TABLE public.asb_prohibited_conduct ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + claim_id uuid, + antisocial_behaviour public.yes_no, + antisocial_behaviour_details varchar(500), + illegal_purposes public.yes_no, + illegal_purposes_details varchar(500), + other_prohibited_conduct public.yes_no, + other_prohibited_conduct_details varchar(500), + claiming_standard_contract public.yes_no, + claiming_standard_contract_details varchar(250), + periodic_contract_agreed public.yes_no, + periodic_contract_details varchar(250) +); + + + +CREATE TABLE public.case_flag ( + id uuid NOT NULL, + pcs_case_id uuid NOT NULL, + flag_ref_data_id uuid NOT NULL, + sub_type_key varchar(50), + sub_type_value varchar(50), + sub_type_value_cy varchar(50), + other_description varchar(50), + other_description_cy varchar(50), + flag_comment varchar(255), + flag_comment_cy varchar(255), + flag_update_comment varchar(255), + date_time_created timestamp without time zone, + date_time_modified timestamp without time zone, + status varchar(50) NOT NULL, + paths varchar(255) NOT NULL +); + + + +CREATE TABLE public.case_link ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + case_id uuid NOT NULL, + linked_case_reference bigint NOT NULL, + ccd_list_id varchar(50), + created_at timestamp without time zone DEFAULT now() +); + + + +CREATE TABLE public.case_link_reason ( + id uuid NOT NULL, + case_link_id integer NOT NULL, + reason_code varchar(100) NOT NULL +); + + + +CREATE TABLE public.case_note ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + created_on timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + created_by varchar(50) NOT NULL, + note varchar(500) NOT NULL, + case_id uuid +); + + + +CREATE TABLE public.case_notification ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + case_id uuid NOT NULL, + provider_notification_id uuid, + submitted_at timestamp without time zone, + scheduled_at timestamp without time zone, + last_updated_at timestamp without time zone NOT NULL, + status varchar(255) NOT NULL, + type varchar(255) NOT NULL, + recipient varchar(255) NOT NULL, + party_id uuid, + claim_id uuid, + claim_type varchar(255) NOT NULL +); + + + +CREATE TABLE public.case_party_flag ( + id uuid NOT NULL, + party_id uuid, + flag_ref_data_id uuid NOT NULL, + sub_type_key varchar(50), + sub_type_value varchar(50), + sub_type_value_cy varchar(50), + other_description varchar(50), + other_description_cy varchar(50), + flag_comment varchar(255), + flag_comment_cy varchar(255), + flag_update_comment varchar(255), + date_time_created timestamp without time zone, + date_time_modified timestamp without time zone, + status varchar(50) NOT NULL, + paths varchar(450) NOT NULL +); + + + +CREATE TABLE public.claim ( + id uuid NOT NULL, + version integer, + case_id uuid, + claimant_type text, + against_trespassers public.yes_no, + due_to_rent_arrears public.yes_no, + claim_costs public.yes_no, + pre_action_protocol_followed public.yes_no, + mediation_attempted public.yes_no, + settlement_attempted public.yes_no, + claimant_circumstances_provided public.yes_no, + claimant_circumstances varchar(950), + additional_defendants public.yes_no, + defendant_circumstances_provided public.yes_no, + defendant_circumstances varchar(950), + additional_reasons_provided public.yes_no, + additional_reasons varchar(6400), + underlessee_or_mortgagee public.yes_no, + additional_underlessees_or_mortgagees public.yes_no, + additional_docs_provided public.yes_no, + gen_app_expected public.yes_no, + language_used text, + pre_action_protocol_incomplete_explanation varchar(250), + is_exempt_landlord public.yes_no, + claim_submitted_date timestamp with time zone, + claim_issued_date timestamp with time zone, + energy_performance_certificate_provided public.yes_no, + gas_safety_report_provided public.yes_no, + electrical_installation_condition_provided public.yes_no, + no_energy_performance_certificate_reason varchar(500), + no_gas_safety_report_reason varchar(500), + no_electrical_installation_condition_reason varchar(500), + claim_form_document_id uuid +); + + + +CREATE TABLE public.claim_activity_log ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + case_id uuid NOT NULL, + party_id uuid, + activity_type varchar NOT NULL, + status varchar NOT NULL, + created_at timestamp without time zone DEFAULT now() NOT NULL, + details jsonb +); + + + +CREATE TABLE public.claim_document ( + claim_id uuid NOT NULL, + document_id uuid NOT NULL +); + + + +CREATE TABLE public.claim_ground ( + id uuid NOT NULL, + claim_id uuid NOT NULL, + category varchar(60) NOT NULL, + code varchar(60) NOT NULL, + reason varchar(500), + description varchar(500), + is_rent_arrears boolean NOT NULL +); + + + +CREATE TABLE public.claim_party ( + claim_id uuid NOT NULL, + party_id uuid NOT NULL, + role text NOT NULL, + rank integer NOT NULL +); + + + +CREATE TABLE public.claim_party_legal_representative ( + party_id uuid NOT NULL, + legal_representative_id uuid NOT NULL, + active public.yes_no, + start_date timestamp without time zone, + end_date timestamp without time zone +); + + + +CREATE TABLE public.contact_preferences ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + contact_by_text public.yes_no, + contact_by_phone public.yes_no, + preference_type public.contact_preference_type, + contact_by_email public.yes_no, + contact_by_post public.yes_no +); + + + +CREATE TABLE public.counter_claim ( + id uuid NOT NULL, + version integer, + sot_id integer, + case_id uuid NOT NULL, + party_id uuid NOT NULL, + claim_type varchar(50), + is_claim_amount_known public.yes_no, + claim_amount numeric(18,2), + estimated_max_claim_amount numeric(18,2), + counterclaim_for varchar(6800), + counterclaim_reasons varchar(6800), + other_order_request_details varchar(6800), + other_order_request_facts varchar(6800), + need_help_with_fees public.yes_no, + applied_for_hwf public.yes_no, + hwf_reference_number varchar(255), + status varchar, + claim_submitted_date timestamp without time zone, + claim_issued_date timestamp without time zone, + last_modified_date timestamp without time zone, + language_used text +); + + + +CREATE TABLE public.counter_claim_party ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + cc_id uuid NOT NULL, + party_id uuid NOT NULL +); + + + +CREATE TABLE public.defendant_response ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + claim_id uuid NOT NULL, + party_id uuid NOT NULL, + free_legal_advice public.yes_no_prefer_not_to_say, + tenancy_start_date_confirmation public.yes_no_not_sure, + tenancy_start_date date, + landlord_registered public.yes_no_not_sure, + defendant_name_confirmation public.yes_no, + sot_id integer, + pcs_case_id uuid NOT NULL, + correspondence_address_confirmation public.yes_no, + possession_notice_received public.yes_no_not_sure, + notice_received_date date, + rent_arrears_amount_confirmation public.yes_no_not_sure, + dispute_claim public.yes_no, + dispute_claim_details varchar(6800), + make_counter_claim public.yes_no, + version integer, + status varchar(60), + response_submitted_date timestamp without time zone, + response_deleted_date timestamp without time zone, + response_received_date timestamp without time zone, + language_used text, + channel varchar(60), + ingestion_source varchar(60), + landlord_licensed public.yes_no_not_sure, + written_terms public.yes_no_not_sure, + other_considerations public.yes_no, + other_considerations_details varchar(6400), + tenancy_type_confirmation public.yes_no_not_sure, + counter_claim_want_to_upload_files public.yes_no, + submission_document_id uuid +); + + + +CREATE TABLE public.document ( + id uuid NOT NULL, + case_id uuid, + url text, + file_name text, + binary_url text, + category_id text DEFAULT 'uncategorisedDocuments'::text NOT NULL, + type text, + description varchar(60), + enf_case_id uuid, + counter_claim_id uuid, + content_type varchar(200), + size bigint, + display_file_name text, + claim_id uuid, + defendant_response_id integer, + party_id uuid, + general_application_id uuid, + submitted_date timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + document_id uuid +); + + + +CREATE TABLE public.eligibility_whitelisted_epim ( + epims_id integer NOT NULL, + eligible_from date NOT NULL, + audit jsonb NOT NULL +); + + + +CREATE TABLE public.enf_case ( + id uuid NOT NULL, + claim_id uuid NOT NULL, + enforcement_order jsonb NOT NULL, + bailiff_date timestamp without time zone, + sot_id integer +); + + + +CREATE TABLE public.enf_risk_profile ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + enf_case_id uuid NOT NULL, + any_risk_to_bailiff public.yes_no_not_sure, + vulnerable_people_present public.yes_no_not_sure, + vulnerable_category varchar(100), + vulnerable_reason_text varchar(6800), + violent_details varchar(6800), + firearms_details varchar(6800), + criminal_details varchar(6800), + verbal_threats_details varchar(6800), + protest_group_details varchar(6800), + police_social_services_details varchar(6800), + animals_details varchar(6800) +); + + + +CREATE TABLE public.enf_selected_defendants ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + enf_case_id uuid NOT NULL, + party_id uuid NOT NULL +); + + + +CREATE TABLE public.enf_warrant ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + enf_case_id uuid NOT NULL, + show_people_who_will_be_evicted_page public.yes_no, + show_people_you_want_to_evict_page public.yes_no, + is_suspended_order public.yes_no, + additional_information_select public.yes_no, + additional_information_details varchar(6800), + correct_name_and_address public.yes_no, + evict_everyone public.yes_no, + is_difficult_to_access_property public.yes_no, + clarification_on_access_difficulty_text varchar(6800), + are_legal_costs_to_be_claimed public.yes_no, + amount_of_legal_costs numeric(10,2), + amount_owed numeric(10,2), + have_land_registry_fees_been_paid public.yes_no, + amount_of_land_registry_fees numeric(10,2), + repayment_choice varchar(20), + amount_of_repayment_costs numeric(10,2), + repayment_summary_markdown text, + defendants_dob_known public.yes_no, + defendants_dob_details varchar(6800), + completed_by public.statement_of_truth_completed_by, + certification text, + agreement_claimant text, + full_name_claimant varchar(100), + position_claimant varchar(100), + agreement_legal_rep text, + full_name_legal_rep varchar(100), + firm_name_legal_rep varchar(100), + position_legal_rep varchar(100), + created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + language_used varchar(30) +); + + + +CREATE TABLE public.enf_warrant_of_restitution ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + enf_case_id uuid NOT NULL, + created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + language_used varchar(30), + how_defendants_returned varchar(6800), + is_difficult_to_access_property public.yes_no, + clarification_on_access_difficulty_text varchar(6800), + additional_information_select public.yes_no, + additional_information_details varchar(6800) +); + + + +CREATE TABLE public.enf_writ ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + enf_case_id uuid NOT NULL, + correct_name_and_address public.yes_no, + has_hired_high_court_enforcement_officer public.yes_no, + hceo_details varchar(120), + has_claim_transferred_to_high_court public.yes_no, + have_land_registry_fees_been_paid public.yes_no, + amount_of_land_registry_fees numeric(10,2), + are_legal_costs_to_be_claimed public.yes_no, + amount_of_legal_costs numeric(10,2), + amount_owed numeric(10,2), + created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + language_used varchar(30), + repayment_choice varchar(20), + amount_of_repayment_costs numeric(10,2), + repayment_summary_markdown text +); + + + +CREATE TABLE public.enf_writ_of_restitution ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + enf_case_id uuid NOT NULL, + created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + language_used varchar(30) +); + + + +CREATE TABLE public.fee_payment ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + party_id uuid, + request_date timestamp without time zone NOT NULL, + service_request_reference varchar(255), + external_reference varchar(255), + amount numeric(19,2), + hwf_id integer, + payment_callback_handler_type varchar(30) NOT NULL, + task_data jsonb, + status varchar(50), + possession_claim_id uuid NOT NULL, + related_entity_id uuid +); + + + +CREATE TABLE public.flag_ref_data ( + id uuid NOT NULL, + flag_code varchar(10), + name varchar(255), + name_cy varchar(255), + hearing_relevant boolean, + available_externally boolean, + visibility varchar(20) +); + + + +CREATE TABLE public.general_application ( + id uuid NOT NULL, + case_id uuid NOT NULL, + sot_id integer, + hwf_id integer, + type varchar(50) NOT NULL, + state varchar(30), + party_id uuid NOT NULL, + within_14_days public.yes_no, + need_hwf public.yes_no, + applied_for_hwf public.yes_no, + other_parties_agreed public.yes_no, + without_notice public.yes_no, + without_notice_reason varchar(6800), + what_order_wanted varchar(6800), + documents_uploaded public.yes_no, + language_used varchar(30), + application_submitted_date timestamp without time zone, + application_issued_date timestamp without time zone, + client_reference varchar(60), + rank integer NOT NULL, + submission_document_id uuid +); + + + +CREATE TABLE public.help_with_fees ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + hwf_reference varchar(60) NOT NULL +); + + + +CREATE TABLE public.household_circumstances ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + defendant_response_id integer NOT NULL, + dependant_children public.yes_no, + dependant_children_details varchar(500), + other_dependants public.yes_no, + other_dependant_details varchar(500), + other_tenants public.yes_no, + other_tenants_details varchar(500), + alternative_accommodation public.yes_no_not_sure, + alternative_accommodation_transfer_date date, + share_additional_circumstances public.yes_no, + additional_circumstances_details varchar(500), + exceptional_hardship public.yes_no, + exceptional_hardship_details varchar(500), + share_income_expense_details public.yes_no, + universal_credit public.yes_no, + uc_application_date date, + priority_debts public.yes_no, + debt_total numeric(18,2), + debt_contribution numeric(18,2), + debt_contribution_frequency varchar(60), + regular_expenses varchar(500), + expense_amount numeric(18,2), + expense_frequency varchar(60) +); + + + +CREATE TABLE public.legal_representative ( + id uuid NOT NULL, + idam_id uuid, + organisation_name varchar(120), + first_name varchar(60), + last_name varchar(60), + email varchar(120), + phone varchar(40), + address_id integer, + organisation_id varchar(64) +); + + + +CREATE TABLE public.notice_of_possession ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + claim_id uuid, + notice_served public.yes_no NOT NULL, + notice_type varchar(60), + serving_method varchar(40), + notice_details varchar(250), + notice_date date, + notice_date_time timestamp without time zone, + notice_statement varchar(500), + unable_to_upload_reason varchar(500), + is_able_to_upload_document public.yes_no, + CONSTRAINT chk_notice_date CHECK (((notice_date IS NULL) OR (notice_date_time IS NULL))) +); + + + +CREATE TABLE public.party ( + id uuid NOT NULL, + version integer, + case_id uuid, + type text, + idam_id uuid, + first_name varchar(60), + last_name varchar(60), + org_name varchar(60), + name_known public.yes_no, + name_overridden public.yes_no, + address_id integer, + address_known public.yes_no, + address_same_as_property public.yes_no, + phone_number_provided public.yes_no, + phone_number varchar(60), + email_address varchar(60), + pcq_id varchar(60), + contact_preferences_id integer, + dob date, + organisation_id varchar(64) +); + + + +CREATE TABLE public.party_access_code ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + case_id uuid NOT NULL, + party_id uuid NOT NULL, + code varchar(100) NOT NULL, + role varchar(20), + created timestamp without time zone +); + + + +CREATE TABLE public.party_attribute_assertion ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + party_id uuid NOT NULL, + evidence_document_id uuid, + attributes_name varchar(255) NOT NULL, + asserted_value text NOT NULL, + asserted_by public.party_attribute_assertion_submitted_by NOT NULL, + status public.party_attribute_assertion_status NOT NULL, + created_at timestamp without time zone NOT NULL, + last_updated_at timestamp without time zone, + created_by uuid NOT NULL, + last_updated_by uuid NOT NULL +); + + + +CREATE TABLE public.payment_agreement ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + defendant_response_id integer NOT NULL, + any_payments_made public.yes_no, + payment_details varchar(500), + paid_money_to_housing_org public.yes_no, + repayment_plan_agreed public.yes_no_not_sure, + repayment_agreed_details varchar(500), + repay_arrears_instalments public.yes_no, + additional_rent_contribution numeric(18,2), + additional_contribution_frequency varchar(50) +); + + + +CREATE TABLE public.pcs_case ( + id uuid NOT NULL, + version integer, + case_reference bigint, + property_address_id integer, + case_management_location integer, + pre_action_protocol_completed boolean, + legislative_country varchar(20), + party_documents jsonb, + claimant_type varchar(50), + region_id integer, + base_location integer +); + + + +CREATE TABLE public.possession_alternatives ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + claim_id uuid, + supension_of_rtb_requested public.yes_no NOT NULL, + supension_of_rtb_housing_act_section varchar(20), + supension_of_rtb_reason varchar(250), + dot_requested public.yes_no NOT NULL, + dot_housing_act_section varchar(20), + dot_statement_served public.yes_no, + dot_statement_details varchar(950), + dot_reason varchar(250) +); + + + +CREATE TABLE public.postcode_court_mapping ( + postcode varchar(20) NOT NULL, + epims_id integer NOT NULL, + legislative_country varchar(80) NOT NULL, + effective_from date NOT NULL, + effective_to date, + audit jsonb NOT NULL +); + + + +CREATE TABLE public.reasonable_adjustments ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + defendant_response_id integer NOT NULL, + reasonable_adjustments_required varchar(250), + reasonable_adjustment_description varchar(500), + hearing_enhancement_description varchar(250), + sign_language_support_description varchar(250), + travel_support_description varchar(250), + welsh_language_requirements varchar(250), + language_interpreter public.yes_no, + language_support_description varchar(250), + considered_vulnerable public.yes_no, + vulnerable_characteristic_description varchar(250) +); + + + +CREATE TABLE public.regular_expenses ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + hc_id integer NOT NULL, + expense_type varchar(30) NOT NULL, + amount numeric(18,2) NOT NULL, + expense_frequency varchar(10) NOT NULL, + CONSTRAINT chk_regular_expense_amount_positive CHECK ((amount >= (0)::numeric)) +); + + + +CREATE TABLE public.regular_income ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + hc_id integer NOT NULL, + other_income_details varchar(500), + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); + + + +CREATE TABLE public.regular_income_item ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + regular_income_id integer NOT NULL, + income_type public.income_type NOT NULL, + amount numeric(18,2), + frequency public.recurrence_frequency, + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT chk_income_item_amount CHECK (((amount IS NULL) OR (amount >= (0)::numeric))) +); + + + +CREATE TABLE public.rent_arrears ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + claim_id uuid, + total_rent_arrears numeric(18,2) NOT NULL, + arrears_judgment_wanted public.yes_no, + recovery_attempted public.yes_no, + recovery_attempt_details varchar(500) +); + + + +CREATE TABLE public.scheduled_tasks ( + task_name text NOT NULL, + task_instance text NOT NULL, + task_data bytea, + execution_time timestamp with time zone NOT NULL, + picked boolean NOT NULL, + picked_by text, + last_success timestamp with time zone, + last_failure timestamp with time zone, + consecutive_failures integer, + last_heartbeat timestamp with time zone, + version bigint NOT NULL, + priority smallint +); + + + +CREATE TABLE public.statement_of_truth ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + claim_id uuid, + completed_by varchar(40), + accepted public.yes_no NOT NULL, + full_name varchar(100) NOT NULL, + firm_name varchar(100), + position_held varchar(100), + completed_date timestamp without time zone +); + + + +CREATE TABLE public.tenancy_licence ( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY, + version integer, + case_id uuid, + type varchar(40) NOT NULL, + other_type_details varchar(500), + start_date date, + rent_amount numeric(18,2), + rent_frequency varchar(20), + other_rent_frequency varchar(60), + rent_per_day numeric(18,2), + calculated_daily_rent_correct public.yes_no, + has_copy_of_tenancy_licence public.yes_no, + reasons_for_no_tenancy_licence varchar(500) +); + + + +ALTER TABLE ONLY draft.draft_case_data + ADD CONSTRAINT unsubmitted_case_data_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.address + ADD CONSTRAINT address_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.asb_prohibited_conduct + ADD CONSTRAINT asb_prohibited_conduct_claim_id_key UNIQUE (claim_id); + + + +ALTER TABLE ONLY public.asb_prohibited_conduct + ADD CONSTRAINT asb_prohibited_conduct_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.case_flag + ADD CONSTRAINT case_flag_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.case_link + ADD CONSTRAINT case_link_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.case_link_reason + ADD CONSTRAINT case_link_reason_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.case_note + ADD CONSTRAINT case_note_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.case_party_flag + ADD CONSTRAINT case_party_flag_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.claim_activity_log + ADD CONSTRAINT claim_activity_log_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.claim_document + ADD CONSTRAINT claim_document_pkey PRIMARY KEY (claim_id, document_id); + + + +ALTER TABLE ONLY public.claim_ground + ADD CONSTRAINT claim_ground_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.claim_party_legal_representative + ADD CONSTRAINT claim_party_legal_representative_pkey PRIMARY KEY (party_id, legal_representative_id); + + + +ALTER TABLE ONLY public.claim_party + ADD CONSTRAINT claim_party_pkey PRIMARY KEY (claim_id, party_id); + + + +ALTER TABLE ONLY public.claim + ADD CONSTRAINT claim_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.contact_preferences + ADD CONSTRAINT contact_preferences_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.counter_claim_party + ADD CONSTRAINT counter_claim_party_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.counter_claim + ADD CONSTRAINT counter_claim_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_claim_party UNIQUE (claim_id, party_id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_sot_id_key UNIQUE (sot_id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.eligibility_whitelisted_epim + ADD CONSTRAINT eligibility_whitelisted_epim_pkey PRIMARY KEY (epims_id); + + + +ALTER TABLE ONLY public.enf_case + ADD CONSTRAINT enf_case_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_risk_profile + ADD CONSTRAINT enf_risk_profile_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_selected_defendants + ADD CONSTRAINT enf_selected_defendants_enf_case_id_party_id_key UNIQUE (enf_case_id, party_id); + + + +ALTER TABLE ONLY public.enf_selected_defendants + ADD CONSTRAINT enf_selected_defendants_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_warrant_of_restitution + ADD CONSTRAINT enf_warrant_of_restitution_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_warrant + ADD CONSTRAINT enf_warrant_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_writ_of_restitution + ADD CONSTRAINT enf_writ_of_restitution_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_writ + ADD CONSTRAINT enf_writ_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.flag_ref_data + ADD CONSTRAINT flag_ref_data_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT general_application_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.help_with_fees + ADD CONSTRAINT help_with_fees_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.household_circumstances + ADD CONSTRAINT household_circumstances_defendant_response_id_key UNIQUE (defendant_response_id); + + + +ALTER TABLE ONLY public.household_circumstances + ADD CONSTRAINT household_circumstances_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.legal_representative + ADD CONSTRAINT legal_representative_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.notice_of_possession + ADD CONSTRAINT notice_of_possession_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.party_access_code + ADD CONSTRAINT party_access_code_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.party_attribute_assertion + ADD CONSTRAINT party_attribute_assertion_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.party + ADD CONSTRAINT party_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.payment_agreement + ADD CONSTRAINT payment_agreement_defendant_response_id_key UNIQUE (defendant_response_id); + + + +ALTER TABLE ONLY public.payment_agreement + ADD CONSTRAINT payment_agreement_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.pcs_case + ADD CONSTRAINT pcs_case_case_reference_key UNIQUE (case_reference); + + + +ALTER TABLE ONLY public.pcs_case + ADD CONSTRAINT pcs_case_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.case_notification + ADD CONSTRAINT pk_case_notification_id PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.fee_payment + ADD CONSTRAINT pk_fee_payment PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.possession_alternatives + ADD CONSTRAINT possession_alternatives_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.postcode_court_mapping + ADD CONSTRAINT postcode_court_mapping_pkey PRIMARY KEY (postcode, epims_id); + + + +ALTER TABLE ONLY public.reasonable_adjustments + ADD CONSTRAINT reasonable_adjustments_defendant_response_id_key UNIQUE (defendant_response_id); + + + +ALTER TABLE ONLY public.reasonable_adjustments + ADD CONSTRAINT reasonable_adjustments_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.regular_expenses + ADD CONSTRAINT regular_expenses_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.regular_income_item + ADD CONSTRAINT regular_income_item_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.regular_income + ADD CONSTRAINT regular_income_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.rent_arrears + ADD CONSTRAINT rent_arrears_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.scheduled_tasks + ADD CONSTRAINT scheduled_tasks_pkey PRIMARY KEY (task_name, task_instance); + + + +ALTER TABLE ONLY public.statement_of_truth + ADD CONSTRAINT statement_of_truth_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.tenancy_licence + ADD CONSTRAINT tenancy_licence_pkey PRIMARY KEY (id); + + + +ALTER TABLE ONLY public.enf_risk_profile + ADD CONSTRAINT unique_risk_profile_per_case UNIQUE (enf_case_id); + + + +ALTER TABLE ONLY public.fee_payment + ADD CONSTRAINT unique_service_request_ref UNIQUE (service_request_reference); + + + +ALTER TABLE ONLY public.enf_warrant_of_restitution + ADD CONSTRAINT unique_warrant_of_restitution_per_enforcement UNIQUE (enf_case_id); + + + +ALTER TABLE ONLY public.enf_warrant + ADD CONSTRAINT unique_warrant_per_enforcement UNIQUE (enf_case_id); + + + +ALTER TABLE ONLY public.enf_writ_of_restitution + ADD CONSTRAINT unique_writ_of_restitution_per_enforcement UNIQUE (enf_case_id); + + + +ALTER TABLE ONLY public.enf_writ + ADD CONSTRAINT unique_writ_per_enforcement UNIQUE (enf_case_id); + + + +ALTER TABLE ONLY public.claim_party + ADD CONSTRAINT uq_claim_role_rank UNIQUE (claim_id, role, rank); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT uq_general_application_case_rank UNIQUE (case_id, rank); + + + +ALTER TABLE ONLY public.regular_income_item + ADD CONSTRAINT uq_income_item_type UNIQUE (regular_income_id, income_type); + + + +ALTER TABLE ONLY public.party_access_code + ADD CONSTRAINT uq_party_access_code_case_code UNIQUE (case_id, code); + + + +ALTER TABLE ONLY public.party_access_code + ADD CONSTRAINT uq_party_access_code_case_party UNIQUE (case_id, party_id); + + + +ALTER TABLE ONLY public.party + ADD CONSTRAINT uq_party_id_case UNIQUE (id, case_id); + + + +ALTER TABLE ONLY public.regular_income + ADD CONSTRAINT uq_regular_income_hc UNIQUE (hc_id); + + + +CREATE INDEX draft_case_data_case_ref_idx ON draft.draft_case_data USING btree (case_reference); + + + +CREATE INDEX draft_case_data_case_reference_idx ON draft.draft_case_data USING btree (case_reference); + + + +CREATE INDEX draft_case_data_party_id_idx ON draft.draft_case_data USING btree (party_id); + + + +CREATE UNIQUE INDEX draft_case_data_unique_idx ON draft.draft_case_data USING btree (case_reference, event_id, idam_user_id, party_id); + + + +CREATE INDEX draft_case_data_user_id_idx ON draft.draft_case_data USING btree (idam_user_id); + + + +CREATE INDEX defendant_response_pcs_case_idx ON public.defendant_response USING btree (pcs_case_id); + + + +CREATE INDEX execution_time_idx ON public.scheduled_tasks USING btree (execution_time); + + + +CREATE UNIQUE INDEX general_application_case_id_client_ref ON public.general_application USING btree (case_id, client_reference); + + + +CREATE INDEX idx_case_flag_pcs_case_id ON public.case_flag USING btree (pcs_case_id); + + + +CREATE INDEX idx_case_link_reason_link ON public.case_link_reason USING btree (case_link_id); + + + +CREATE INDEX idx_case_note_case_id ON public.case_note USING btree (case_id); + + + +CREATE INDEX idx_case_party_flag_party_id ON public.case_party_flag USING btree (party_id); + + + +CREATE INDEX idx_claim_activity_log_case_id ON public.claim_activity_log USING btree (case_id); + + + +CREATE INDEX idx_claim_activity_log_party_id ON public.claim_activity_log USING btree (party_id); + + + +CREATE INDEX idx_claim_activity_log_type_status ON public.claim_activity_log USING btree (activity_type, status); + + + +CREATE INDEX idx_claim_case_id ON public.claim USING btree (case_id); + + + +CREATE INDEX idx_claim_claim_form_document_id ON public.claim USING btree (claim_form_document_id); + + + +CREATE INDEX idx_claim_document_claim_id ON public.claim_document USING btree (claim_id); + + + +CREATE INDEX idx_claim_document_document_id ON public.claim_document USING btree (document_id); + + + +CREATE INDEX idx_claim_ground_claim_id ON public.claim_ground USING btree (claim_id); + + + +CREATE INDEX idx_counter_claim_party_party_id ON public.counter_claim_party USING btree (party_id); + + + +CREATE INDEX idx_defendant_response_submission_document_id ON public.defendant_response USING btree (submission_document_id); + + + +CREATE INDEX idx_document_case_id ON public.document USING btree (case_id); + + + +CREATE INDEX idx_document_claim_id ON public.document USING btree (claim_id); + + + +CREATE INDEX idx_document_counter_claim_id ON public.document USING btree (counter_claim_id); + + + +CREATE INDEX idx_document_defendant_response_id ON public.document USING btree (defendant_response_id); + + + +CREATE INDEX idx_document_enf_case_id ON public.document USING btree (enf_case_id); + + + +CREATE INDEX idx_document_general_application_id ON public.document USING btree (general_application_id); + + + +CREATE INDEX idx_document_party_id ON public.document USING btree (party_id); + + + +CREATE INDEX idx_eligibility_whitelisted_epim_eligible_from ON public.eligibility_whitelisted_epim USING btree (eligible_from); + + + +CREATE INDEX idx_enf_case_claim_id ON public.enf_case USING btree (claim_id); + + + +CREATE INDEX idx_enf_case_sot_id ON public.enf_case USING btree (sot_id); + + + +CREATE INDEX idx_enf_risk_profile_case_id ON public.enf_risk_profile USING btree (enf_case_id); + + + +CREATE INDEX idx_enf_selected_defendants_party ON public.enf_selected_defendants USING btree (party_id); + + + +CREATE INDEX idx_fee_payment_possession_claim_id ON public.fee_payment USING btree (possession_claim_id); + + + +CREATE INDEX idx_fee_payment_request_reference ON public.fee_payment USING btree (service_request_reference); + + + +CREATE INDEX idx_idam_id ON public.party USING btree (idam_id); + + + +CREATE INDEX idx_income_item_regular_income_id ON public.regular_income_item USING btree (regular_income_id); + + + +CREATE INDEX idx_notice_of_possession_claim_id ON public.notice_of_possession USING btree (claim_id); + + + +CREATE INDEX idx_party_access_code_case_code ON public.party_access_code USING btree (case_id, code); + + + +CREATE INDEX idx_party_attribute_assertion_party_id ON public.party_attribute_assertion USING btree (party_id); + + + +CREATE INDEX idx_party_case_id ON public.party USING btree (case_id); + + + +CREATE INDEX idx_party_id ON public.claim_party USING btree (party_id); + + + +CREATE INDEX idx_pcs_case_party_documents ON public.pcs_case USING gin (party_documents); + + + +CREATE INDEX idx_possession_alternatives_claim_id ON public.possession_alternatives USING btree (claim_id); + + + +CREATE INDEX idx_postcode ON public.postcode_court_mapping USING btree (postcode); + + + +CREATE INDEX idx_regular_income_hc_id ON public.regular_income USING btree (hc_id); + + + +CREATE INDEX idx_rent_arrears_claim_id ON public.rent_arrears USING btree (claim_id); + + + +CREATE INDEX idx_statement_of_truth_claim_id ON public.statement_of_truth USING btree (claim_id); + + + +CREATE INDEX idx_tenancy_licence_case_id ON public.tenancy_licence USING btree (case_id); + + + +CREATE INDEX last_heartbeat_idx ON public.scheduled_tasks USING btree (last_heartbeat); + + + +CREATE INDEX priority_execution_time_idx ON public.scheduled_tasks USING btree (priority DESC, execution_time); + + + +CREATE UNIQUE INDEX ux_case_link_unique ON public.case_link USING btree (case_id, linked_case_reference); + + + +CREATE UNIQUE INDEX ux_counter_claim_party ON public.counter_claim_party USING btree (cc_id, party_id); + + + +CREATE TRIGGER postcode_court_mapping_trigger BEFORE INSERT OR UPDATE ON public.postcode_court_mapping FOR EACH ROW EXECUTE FUNCTION public.postcode_court_mapping_trigger_func(); + + + +ALTER TABLE ONLY public.asb_prohibited_conduct + ADD CONSTRAINT asb_prohibited_conduct_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.case_flag + ADD CONSTRAINT case_flag_flag_ref_data_id_fkey FOREIGN KEY (flag_ref_data_id) REFERENCES public.flag_ref_data(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.case_flag + ADD CONSTRAINT case_flag_pcs_case_id_fkey FOREIGN KEY (pcs_case_id) REFERENCES public.pcs_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.case_link + ADD CONSTRAINT case_link_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.case_link_reason + ADD CONSTRAINT case_link_reason_case_link_id_fkey FOREIGN KEY (case_link_id) REFERENCES public.case_link(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.case_note + ADD CONSTRAINT case_note_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.case_party_flag + ADD CONSTRAINT case_party_flag_flag_ref_data_id_fkey FOREIGN KEY (flag_ref_data_id) REFERENCES public.flag_ref_data(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.case_party_flag + ADD CONSTRAINT case_party_flag_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.claim_activity_log + ADD CONSTRAINT claim_activity_log_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.claim_activity_log + ADD CONSTRAINT claim_activity_log_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.claim + ADD CONSTRAINT claim_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.claim + ADD CONSTRAINT claim_claim_form_document_id_fkey FOREIGN KEY (claim_form_document_id) REFERENCES public.document(id); + + + +ALTER TABLE ONLY public.claim_document + ADD CONSTRAINT claim_document_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.claim_document + ADD CONSTRAINT claim_document_document_id_fkey FOREIGN KEY (document_id) REFERENCES public.document(id); + + + +ALTER TABLE ONLY public.claim_ground + ADD CONSTRAINT claim_ground_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.claim_party + ADD CONSTRAINT claim_party_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.claim_party_legal_representative + ADD CONSTRAINT claim_party_legal_representative_legal_representative_id_fkey FOREIGN KEY (legal_representative_id) REFERENCES public.legal_representative(id); + + + +ALTER TABLE ONLY public.claim_party_legal_representative + ADD CONSTRAINT claim_party_legal_representative_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.claim_party + ADD CONSTRAINT claim_party_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.counter_claim + ADD CONSTRAINT counter_claim_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.counter_claim_party + ADD CONSTRAINT counter_claim_party_cc_id_fkey FOREIGN KEY (cc_id) REFERENCES public.counter_claim(id); + + + +ALTER TABLE ONLY public.counter_claim + ADD CONSTRAINT counter_claim_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.counter_claim_party + ADD CONSTRAINT counter_claim_party_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.counter_claim + ADD CONSTRAINT counter_claim_sot_id_fkey FOREIGN KEY (sot_id) REFERENCES public.statement_of_truth(id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_pcs_case_id_fkey FOREIGN KEY (pcs_case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_sot_id_fkey FOREIGN KEY (sot_id) REFERENCES public.statement_of_truth(id); + + + +ALTER TABLE ONLY public.defendant_response + ADD CONSTRAINT defendant_response_submission_document_id_fkey FOREIGN KEY (submission_document_id) REFERENCES public.document(id) ON DELETE SET NULL; + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_counter_claim_id_fkey FOREIGN KEY (counter_claim_id) REFERENCES public.counter_claim(id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_defendant_response_id_fkey FOREIGN KEY (defendant_response_id) REFERENCES public.defendant_response(id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_general_application_id_fkey FOREIGN KEY (general_application_id) REFERENCES public.general_application(id); + + + +ALTER TABLE ONLY public.document + ADD CONSTRAINT document_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.enf_case + ADD CONSTRAINT enf_case_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.enf_case + ADD CONSTRAINT enf_case_sot_id_fkey FOREIGN KEY (sot_id) REFERENCES public.statement_of_truth(id); + + + +ALTER TABLE ONLY public.enf_risk_profile + ADD CONSTRAINT enf_risk_profile_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.enf_selected_defendants + ADD CONSTRAINT enf_selected_defendants_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.enf_selected_defendants + ADD CONSTRAINT enf_selected_defendants_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.enf_warrant + ADD CONSTRAINT enf_warrant_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.enf_warrant_of_restitution + ADD CONSTRAINT enf_warrant_of_restitution_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.enf_writ + ADD CONSTRAINT enf_writ_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.enf_writ_of_restitution + ADD CONSTRAINT enf_writ_of_restitution_enf_case_id_fkey FOREIGN KEY (enf_case_id) REFERENCES public.enf_case(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.case_notification + ADD CONSTRAINT fk_case_notification_case FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.case_notification + ADD CONSTRAINT fk_case_notification_claim FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.case_notification + ADD CONSTRAINT fk_case_notification_party FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.fee_payment + ADD CONSTRAINT fk_fee_payment_claim FOREIGN KEY (possession_claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.fee_payment + ADD CONSTRAINT fk_fee_payment_help_with_fees FOREIGN KEY (hwf_id) REFERENCES public.help_with_fees(id); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT fk_general_application_party_case FOREIGN KEY (party_id, case_id) REFERENCES public.party(id, case_id); + + + +ALTER TABLE ONLY public.regular_income_item + ADD CONSTRAINT fk_income_item_regular_income FOREIGN KEY (regular_income_id) REFERENCES public.regular_income(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.party_access_code + ADD CONSTRAINT fk_party_access_code_party FOREIGN KEY (party_id, case_id) REFERENCES public.party(id, case_id); + + + +ALTER TABLE ONLY public.regular_income + ADD CONSTRAINT fk_regular_income_hc FOREIGN KEY (hc_id) REFERENCES public.household_circumstances(id) ON DELETE CASCADE; + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT general_application_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT general_application_hwf_id_fkey FOREIGN KEY (hwf_id) REFERENCES public.help_with_fees(id); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT general_application_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT general_application_sot_id_fkey FOREIGN KEY (sot_id) REFERENCES public.statement_of_truth(id); + + + +ALTER TABLE ONLY public.general_application + ADD CONSTRAINT general_application_submission_document_id_fkey FOREIGN KEY (submission_document_id) REFERENCES public.document(id); + + + +ALTER TABLE ONLY public.household_circumstances + ADD CONSTRAINT household_circumstances_defendant_response_id_fkey FOREIGN KEY (defendant_response_id) REFERENCES public.defendant_response(id); + + + +ALTER TABLE ONLY public.legal_representative + ADD CONSTRAINT legal_representative_address_id_fkey FOREIGN KEY (address_id) REFERENCES public.address(id); + + + +ALTER TABLE ONLY public.notice_of_possession + ADD CONSTRAINT notice_of_possession_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.party_access_code + ADD CONSTRAINT party_access_code_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.party + ADD CONSTRAINT party_address_id_fkey FOREIGN KEY (address_id) REFERENCES public.address(id); + + + +ALTER TABLE ONLY public.party_attribute_assertion + ADD CONSTRAINT party_attribute_assertion_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.party_attribute_assertion + ADD CONSTRAINT party_attribute_assertion_evidence_document_id_fkey FOREIGN KEY (evidence_document_id) REFERENCES public.document(id); + + + +ALTER TABLE ONLY public.party_attribute_assertion + ADD CONSTRAINT party_attribute_assertion_last_updated_by_fkey FOREIGN KEY (last_updated_by) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.party_attribute_assertion + ADD CONSTRAINT party_attribute_assertion_party_id_fkey FOREIGN KEY (party_id) REFERENCES public.party(id); + + + +ALTER TABLE ONLY public.party + ADD CONSTRAINT party_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + +ALTER TABLE ONLY public.party + ADD CONSTRAINT party_contact_preferences_id_fkey FOREIGN KEY (contact_preferences_id) REFERENCES public.contact_preferences(id); + + + +ALTER TABLE ONLY public.payment_agreement + ADD CONSTRAINT payment_agreement_defendant_response_id_fkey FOREIGN KEY (defendant_response_id) REFERENCES public.defendant_response(id); + + + +ALTER TABLE ONLY public.pcs_case + ADD CONSTRAINT pcs_case_property_address_id_fkey FOREIGN KEY (property_address_id) REFERENCES public.address(id); + + + +ALTER TABLE ONLY public.possession_alternatives + ADD CONSTRAINT possession_alternatives_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.reasonable_adjustments + ADD CONSTRAINT reasonable_adjustments_defendant_response_id_fkey FOREIGN KEY (defendant_response_id) REFERENCES public.defendant_response(id); + + + +ALTER TABLE ONLY public.regular_expenses + ADD CONSTRAINT regular_expenses_hc_id_fkey FOREIGN KEY (hc_id) REFERENCES public.household_circumstances(id); + + + +ALTER TABLE ONLY public.rent_arrears + ADD CONSTRAINT rent_arrears_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.statement_of_truth + ADD CONSTRAINT statement_of_truth_claim_id_fkey FOREIGN KEY (claim_id) REFERENCES public.claim(id); + + + +ALTER TABLE ONLY public.tenancy_licence + ADD CONSTRAINT tenancy_licence_case_id_fkey FOREIGN KEY (case_id) REFERENCES public.pcs_case(id); + + + + diff --git a/src/main/resources/db/migration/V002__postcode_court_dates.sql b/src/main/resources/db/migration/V002__postcode_court_dates.sql deleted file mode 100644 index 9469c451fb..0000000000 --- a/src/main/resources/db/migration/V002__postcode_court_dates.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE public.postcode_court_mapping -ALTER COLUMN effective_from TYPE DATE, -ALTER COLUMN effective_from SET NOT NULL, -ALTER COLUMN effective_to TYPE DATE; diff --git a/src/main/resources/db/migration/V003__clean_postcode_data.sql b/src/main/resources/db/migration/V003__clean_postcode_data.sql deleted file mode 100644 index 00387da5e7..0000000000 --- a/src/main/resources/db/migration/V003__clean_postcode_data.sql +++ /dev/null @@ -1,2 +0,0 @@ -UPDATE postcode_court_mapping -SET postcode = upper(regexp_replace(postcode, '\s', '', 'g')); diff --git a/src/main/resources/db/migration/V004__case_notification.sql b/src/main/resources/db/migration/V004__case_notification.sql deleted file mode 100644 index cd919f31a5..0000000000 --- a/src/main/resources/db/migration/V004__case_notification.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE case_notification -( - notification_id UUID NOT NULL, - case_id UUID NOT NULL, - provider_notification_id UUID, - submitted_at TIMESTAMP WITHOUT TIME ZONE, - scheduled_at TIMESTAMP WITHOUT TIME ZONE, - last_updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL, - status VARCHAR(255) NOT NULL, - type VARCHAR(255) NOT NULL, - recipient VARCHAR(255) NOT NULL, - CONSTRAINT pk_case_notification PRIMARY KEY (notification_id) -); diff --git a/src/main/resources/db/migration/V005__scheduled_tasks.sql b/src/main/resources/db/migration/V005__scheduled_tasks.sql deleted file mode 100644 index e32b5d0b89..0000000000 --- a/src/main/resources/db/migration/V005__scheduled_tasks.sql +++ /dev/null @@ -1,19 +0,0 @@ -create table scheduled_tasks ( - task_name text not null, - task_instance text not null, - task_data bytea, - execution_time timestamp with time zone not null, - picked BOOLEAN not null, - picked_by text, - last_success timestamp with time zone, - last_failure timestamp with time zone, - consecutive_failures INT, - last_heartbeat timestamp with time zone, - version BIGINT not null, - priority SMALLINT, - PRIMARY KEY (task_name, task_instance) -); - -CREATE INDEX execution_time_idx ON scheduled_tasks (execution_time); -CREATE INDEX last_heartbeat_idx ON scheduled_tasks (last_heartbeat); -CREATE INDEX priority_execution_time_idx on scheduled_tasks (priority desc, execution_time asc); diff --git a/src/main/resources/db/migration/V006__case_tables.sql b/src/main/resources/db/migration/V006__case_tables.sql deleted file mode 100644 index a43ac7db96..0000000000 --- a/src/main/resources/db/migration/V006__case_tables.sql +++ /dev/null @@ -1,20 +0,0 @@ -create table address ( - id uuid primary key, - version integer, - address_line1 varchar(100), - address_line2 varchar(100), - address_line3 varchar(100), - post_town varchar(100), - county varchar(100), - postcode varchar(10), - country varchar(100) -); - -create table pcs_case ( - id uuid primary key, - version integer, - case_reference bigint unique, - applicant_forename varchar(100), - applicant_surname varchar(100), - property_address_id uuid references address (id) -); diff --git a/src/main/resources/db/migration/V007__party_table.sql b/src/main/resources/db/migration/V007__party_table.sql deleted file mode 100644 index 524096ff43..0000000000 --- a/src/main/resources/db/migration/V007__party_table.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE party ( - id UUID PRIMARY KEY, - case_id UUID REFERENCES pcs_case (id), - version INTEGER, - idam_id UUID, - forename VARCHAR(100), - surname VARCHAR(100), - pcq_id UUID, - active BOOLEAN NOT NULL DEFAULT TRUE -); - -CREATE INDEX idx_idam_id ON party (idam_id); diff --git a/src/main/resources/db/migration/V008__court_eligibility_table.sql b/src/main/resources/db/migration/V008__court_eligibility_table.sql deleted file mode 100644 index 17b26cb7a8..0000000000 --- a/src/main/resources/db/migration/V008__court_eligibility_table.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE eligibility_whitelisted_epim ( - epims_id INT NOT NULL, - eligible_from DATE NOT NULL, - audit JSONB NOT NULL, - PRIMARY KEY (epims_id) -); - -CREATE INDEX idx_eligibility_whitelisted_epim_eligible_from ON eligibility_whitelisted_epim(eligible_from); \ No newline at end of file diff --git a/src/main/resources/db/migration/V009__rename_epimid_column.sql b/src/main/resources/db/migration/V009__rename_epimid_column.sql deleted file mode 100644 index b8916ed805..0000000000 --- a/src/main/resources/db/migration/V009__rename_epimid_column.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE postcode_court_mapping - RENAME COLUMN epimid TO epims_id; - diff --git a/src/main/resources/db/migration/V010__case_management.sql b/src/main/resources/db/migration/V010__case_management.sql deleted file mode 100644 index c310eb9fac..0000000000 --- a/src/main/resources/db/migration/V010__case_management.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE public.pcs_case -ADD COLUMN case_management_location INT, -ADD COLUMN payment_status VARCHAR(20); diff --git a/src/main/resources/db/migration/V011__claimant_name.sql b/src/main/resources/db/migration/V011__claimant_name.sql deleted file mode 100644 index eb2edbde46..0000000000 --- a/src/main/resources/db/migration/V011__claimant_name.sql +++ /dev/null @@ -1,26 +0,0 @@ -ALTER TABLE public.pcs_case -DROP COLUMN applicant_forename; - -ALTER TABLE public.pcs_case -DROP COLUMN applicant_surname; - - -CREATE TABLE public.claim -( - id uuid primary key, - version integer, - case_id uuid references public.pcs_case (id), - created timestamp with time zone, - summary varchar(255), - state varchar(40) -); - -CREATE TABLE public.claim_party -( - version integer, - claim_id uuid references public.claim (id), - party_id uuid references public.party (id), - role varchar(40) not null, - - primary key (claim_id, party_id) -); diff --git a/src/main/resources/db/migration/V012__contact_preferences.sql b/src/main/resources/db/migration/V012__contact_preferences.sql deleted file mode 100644 index f2c7a8e869..0000000000 --- a/src/main/resources/db/migration/V012__contact_preferences.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE public.party - ADD COLUMN contact_address_id UUID, - ADD COLUMN contact_email VARCHAR(100), - ADD COLUMN contact_phone_number VARCHAR(20), - ADD CONSTRAINT fk_contact_address - FOREIGN KEY (contact_address_id) - REFERENCES public.address(id); diff --git a/src/main/resources/db/migration/V013__add_pre_action_protocol_completed.sql b/src/main/resources/db/migration/V013__add_pre_action_protocol_completed.sql deleted file mode 100644 index 29ea026a51..0000000000 --- a/src/main/resources/db/migration/V013__add_pre_action_protocol_completed.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN pre_action_protocol_completed BOOLEAN; \ No newline at end of file diff --git a/src/main/resources/db/migration/V014__add_mediation_and_settlement_attempted_fields.sql b/src/main/resources/db/migration/V014__add_mediation_and_settlement_attempted_fields.sql deleted file mode 100644 index b926284f19..0000000000 --- a/src/main/resources/db/migration/V014__add_mediation_and_settlement_attempted_fields.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN mediation_attempted BOOLEAN; -ALTER TABLE pcs_case ADD COLUMN mediation_attempted_details TEXT; -ALTER TABLE pcs_case ADD COLUMN settlement_attempted BOOLEAN; -ALTER TABLE pcs_case ADD COLUMN settlement_attempted_details TEXT; \ No newline at end of file diff --git a/src/main/resources/db/migration/V015__add_tenancy_licence_column.sql b/src/main/resources/db/migration/V015__add_tenancy_licence_column.sql deleted file mode 100644 index ea930e35d7..0000000000 --- a/src/main/resources/db/migration/V015__add_tenancy_licence_column.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN tenancy_licence JSONB; \ No newline at end of file diff --git a/src/main/resources/db/migration/V016__defendant_details.sql b/src/main/resources/db/migration/V016__defendant_details.sql deleted file mode 100644 index f0f4e6b3b5..0000000000 --- a/src/main/resources/db/migration/V016__defendant_details.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN defendant_details JSONB; diff --git a/src/main/resources/db/migration/V017__case_legislative_country_column.sql b/src/main/resources/db/migration/V017__case_legislative_country_column.sql deleted file mode 100644 index 4b47abeda2..0000000000 --- a/src/main/resources/db/migration/V017__case_legislative_country_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE pcs_case - ADD COLUMN legislative_country VARCHAR(20); diff --git a/src/main/resources/db/migration/V018__unsubmitted_data.sql b/src/main/resources/db/migration/V018__unsubmitted_data.sql deleted file mode 100644 index 77f98cc17e..0000000000 --- a/src/main/resources/db/migration/V018__unsubmitted_data.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE SCHEMA draft; - -CREATE TABLE draft.unsubmitted_case_data ( - id UUID PRIMARY KEY, - case_reference BIGINT NOT NULL, - case_data JSONB -); - -CREATE INDEX unsubmitted_case_data_case_reference_idx ON draft.unsubmitted_case_data (case_reference); diff --git a/src/main/resources/db/migration/V019__add_possession_grounds.sql b/src/main/resources/db/migration/V019__add_possession_grounds.sql deleted file mode 100644 index ba7ba462f4..0000000000 --- a/src/main/resources/db/migration/V019__add_possession_grounds.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN possession_grounds JSONB; diff --git a/src/main/resources/db/migration/V020__claim_ground.sql b/src/main/resources/db/migration/V020__claim_ground.sql deleted file mode 100644 index e04faf7050..0000000000 --- a/src/main/resources/db/migration/V020__claim_ground.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE claim_ground ( - id UUID PRIMARY KEY, - claim_id UUID NOT NULL REFERENCES claim (id), - ground_id VARCHAR(80) NOT NULL, - ground_reason VARCHAR(500) -); diff --git a/src/main/resources/db/migration/V021__add_costs_claimed_to_claim.sql b/src/main/resources/db/migration/V021__add_costs_claimed_to_claim.sql deleted file mode 100644 index 2b2e6ca54b..0000000000 --- a/src/main/resources/db/migration/V021__add_costs_claimed_to_claim.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public.claim -ADD COLUMN costs_claimed BOOLEAN NOT NULL; diff --git a/src/main/resources/db/migration/V022__add_ground_description.sql b/src/main/resources/db/migration/V022__add_ground_description.sql deleted file mode 100644 index 8ff80ff297..0000000000 --- a/src/main/resources/db/migration/V022__add_ground_description.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE public.claim_ground - ADD COLUMN ground_description VARCHAR(500) diff --git a/src/main/resources/db/migration/V023__claim_other_reasons.sql b/src/main/resources/db/migration/V023__claim_other_reasons.sql deleted file mode 100644 index 46aca56901..0000000000 --- a/src/main/resources/db/migration/V023__claim_other_reasons.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE claim - ADD COLUMN additional_reasons VARCHAR(6400); diff --git a/src/main/resources/db/migration/V024__add_application_with_claim_column.sql b/src/main/resources/db/migration/V024__add_application_with_claim_column.sql deleted file mode 100644 index 8440834ab7..0000000000 --- a/src/main/resources/db/migration/V024__add_application_with_claim_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE claim ADD COLUMN application_with_claim BOOLEAN; - diff --git a/src/main/resources/db/migration/V025__defendant_circumstances.sql b/src/main/resources/db/migration/V025__defendant_circumstances.sql deleted file mode 100644 index 3d451b38f1..0000000000 --- a/src/main/resources/db/migration/V025__defendant_circumstances.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE claim - ADD COLUMN defendant_circumstances VARCHAR(950); diff --git a/src/main/resources/db/migration/V026__claimant_circumstances.sql b/src/main/resources/db/migration/V026__claimant_circumstances.sql deleted file mode 100644 index 6339cdfd88..0000000000 --- a/src/main/resources/db/migration/V026__claimant_circumstances.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE claim ADD COLUMN claimant_circumstances VARCHAR(950); diff --git a/src/main/resources/db/migration/V027__add_party_documents_column.sql b/src/main/resources/db/migration/V027__add_party_documents_column.sql deleted file mode 100644 index ad9dae303a..0000000000 --- a/src/main/resources/db/migration/V027__add_party_documents_column.sql +++ /dev/null @@ -1,11 +0,0 @@ --- Add party_documents column to pcs_case table --- This column will store document metadata and references for party documents - -ALTER TABLE pcs_case -ADD COLUMN party_documents JSONB; - --- Add comment to describe the column purpose -COMMENT ON COLUMN pcs_case.party_documents IS 'Stores party document metadata and references in JSONB format'; - --- Create index for better query performance on JSONB column -CREATE INDEX idx_pcs_case_party_documents ON pcs_case USING GIN (party_documents); diff --git a/src/main/resources/db/migration/V028__drop_payment_status.sql b/src/main/resources/db/migration/V028__drop_payment_status.sql deleted file mode 100644 index 335fc21691..0000000000 --- a/src/main/resources/db/migration/V028__drop_payment_status.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE pcs_case - DROP COLUMN payment_status; diff --git a/src/main/resources/db/migration/V029__suspension_of_right_to_buy.sql b/src/main/resources/db/migration/V029__suspension_of_right_to_buy.sql deleted file mode 100644 index 286766d548..0000000000 --- a/src/main/resources/db/migration/V029__suspension_of_right_to_buy.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE claim - ADD COLUMN suspension_of_right_to_buy_housing_act VARCHAR(30), - ADD COLUMN suspension_of_right_to_buy_reason VARCHAR(250); diff --git a/src/main/resources/db/migration/V030__demotion_of_tenancy.sql b/src/main/resources/db/migration/V030__demotion_of_tenancy.sql deleted file mode 100644 index c2900e7912..0000000000 --- a/src/main/resources/db/migration/V030__demotion_of_tenancy.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE claim - ADD COLUMN demotion_of_tenancy_housing_act VARCHAR(30), - ADD COLUMN demotion_of_tenancy_reason VARCHAR(250), - ADD COLUMN statement_of_express_terms_details VARCHAR(950); \ No newline at end of file diff --git a/src/main/resources/db/migration/V031__add_language_used_column.sql b/src/main/resources/db/migration/V031__add_language_used_column.sql deleted file mode 100644 index f533497299..0000000000 --- a/src/main/resources/db/migration/V031__add_language_used_column.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE claim ADD COLUMN language_used VARCHAR(30); \ No newline at end of file diff --git a/src/main/resources/db/migration/V032__add_claimant_type_column.sql b/src/main/resources/db/migration/V032__add_claimant_type_column.sql deleted file mode 100644 index cefd9c648f..0000000000 --- a/src/main/resources/db/migration/V032__add_claimant_type_column.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Add claimant_type column to pcs_case table if it doesn't exist -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.columns - WHERE table_name = 'pcs_case' AND column_name = 'claimant_type') THEN - ALTER TABLE pcs_case ADD COLUMN claimant_type VARCHAR(50); - END IF; -END $$; diff --git a/src/main/resources/db/migration/V033__draft_table_rename.sql b/src/main/resources/db/migration/V033__draft_table_rename.sql deleted file mode 100644 index 35207a3f1b..0000000000 --- a/src/main/resources/db/migration/V033__draft_table_rename.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Rename the table from unsubmitted_case_data to draft_case_data -ALTER TABLE draft.unsubmitted_case_data RENAME TO draft_case_data; - --- Rename the existing index to match the new table name -ALTER INDEX draft.unsubmitted_case_data_case_reference_idx RENAME TO draft_case_data_case_reference_idx; diff --git a/src/main/resources/db/migration/V034__add_prohibited_conduct_column.sql b/src/main/resources/db/migration/V034__add_prohibited_conduct_column.sql deleted file mode 100644 index bc2a22d02e..0000000000 --- a/src/main/resources/db/migration/V034__add_prohibited_conduct_column.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add prohibited_conduct JSONB column to claim table -ALTER TABLE public.claim -ADD COLUMN prohibited_conduct JSONB; diff --git a/src/main/resources/db/migration/V035__underlessee_mortgagee_details.sql b/src/main/resources/db/migration/V035__underlessee_mortgagee_details.sql deleted file mode 100644 index f7441d0389..0000000000 --- a/src/main/resources/db/migration/V035__underlessee_mortgagee_details.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN underlessee_mortgagee_details JSONB; diff --git a/src/main/resources/db/migration/V036__add_asb_question_column.sql b/src/main/resources/db/migration/V036__add_asb_question_column.sql deleted file mode 100644 index 922dcff1e5..0000000000 --- a/src/main/resources/db/migration/V036__add_asb_question_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE claim - ADD COLUMN asb_questions JSONB; \ No newline at end of file diff --git a/src/main/resources/db/migration/V037__add_statement_of_truth_column.sql b/src/main/resources/db/migration/V037__add_statement_of_truth_column.sql deleted file mode 100644 index 00861e89d7..0000000000 --- a/src/main/resources/db/migration/V037__add_statement_of_truth_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN statement_of_truth JSONB; - diff --git a/src/main/resources/db/migration/V038__enforcement_schema_table.sql b/src/main/resources/db/migration/V038__enforcement_schema_table.sql deleted file mode 100644 index 1a0f714591..0000000000 --- a/src/main/resources/db/migration/V038__enforcement_schema_table.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE SCHEMA enforcement; - -CREATE TABLE enforcement.enf_case ( - id uuid PRIMARY KEY, - claim_id uuid references public.claim (id) not null, - enforcement_order JSONB not null -); \ No newline at end of file diff --git a/src/main/resources/db/migration/V039__add_event_id_to_draft_table.sql b/src/main/resources/db/migration/V039__add_event_id_to_draft_table.sql deleted file mode 100644 index c5b8f761e1..0000000000 --- a/src/main/resources/db/migration/V039__add_event_id_to_draft_table.sql +++ /dev/null @@ -1,12 +0,0 @@ --- Add event_id column to table with a default value for existing rows -ALTER TABLE draft.draft_case_data ADD COLUMN event_id VARCHAR(70); - --- Set default value for existing cases -UPDATE draft.draft_case_data SET event_id = 'resumePossessionClaim'; - --- Make the column NOT NULL after existing data has been populated -ALTER TABLE draft.draft_case_data ALTER COLUMN event_id SET NOT NULL; - -CREATE UNIQUE INDEX unsubmitted_case_data_case_event_unique_idx - ON draft.draft_case_data(case_reference, event_id); - diff --git a/src/main/resources/db/migration/V040__add_org_name_to_party.sql b/src/main/resources/db/migration/V040__add_org_name_to_party.sql deleted file mode 100644 index 5a6dd14aa5..0000000000 --- a/src/main/resources/db/migration/V040__add_org_name_to_party.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE public.party - ADD COLUMN org_name VARCHAR(255); - diff --git a/src/main/resources/db/migration/V041__add_party_access_code_table.sql b/src/main/resources/db/migration/V041__add_party_access_code_table.sql deleted file mode 100644 index 43fbb2bf3e..0000000000 --- a/src/main/resources/db/migration/V041__add_party_access_code_table.sql +++ /dev/null @@ -1,13 +0,0 @@ - -CREATE TABLE party_access_code ( - id UUID PRIMARY KEY, - case_id UUID NOT NULL REFERENCES pcs_case(id), - party_id UUID NOT NULL, --Once we move to using party entities, this should be set as the FK to party(id) - code VARCHAR(12) NOT NULL, - role VARCHAR(20), - created TIMESTAMP, - CONSTRAINT uq_party_access_code_case_code UNIQUE (case_id, code) -); - -CREATE INDEX idx_party_access_code_case_code ON party_access_code (case_id, code); - diff --git a/src/main/resources/db/migration/V042__party_tables.sql b/src/main/resources/db/migration/V042__party_tables.sql deleted file mode 100644 index 332a6ac10d..0000000000 --- a/src/main/resources/db/migration/V042__party_tables.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TYPE YES_NO AS ENUM ('YES', 'NO'); - -DROP TABLE public.claim_party; -DROP TABLE public.party; - -CREATE TABLE public.party ( - id UUID PRIMARY KEY, - version INTEGER, - case_id UUID REFERENCES public.pcs_case (id), - type TEXT, - idam_id UUID, - first_name VARCHAR(60), - last_name VARCHAR(60), - org_name VARCHAR(60), - name_known YES_NO, - name_overridden YES_NO, - address_id UUID REFERENCES public.address (id), - address_known YES_NO, - address_same_as_property YES_NO, - phone_number_provided YES_NO, - phone_number VARCHAR(60), - email_address VARCHAR(60), - pcq_id VARCHAR(60) -); - -CREATE INDEX idx_idam_id ON public.party (idam_id); - -CREATE TABLE public.claim_party ( - claim_id UUID REFERENCES public.claim (id), - party_id UUID REFERENCES public.party (id), - role TEXT NOT NULL, - - PRIMARY KEY (claim_id, party_id) -); - -ALTER TABLE public.pcs_case DROP COLUMN defendant_details; -ALTER TABLE public.pcs_case DROP COLUMN underlessee_mortgagee_details; diff --git a/src/main/resources/db/migration/V043__update_claim_table.sql b/src/main/resources/db/migration/V043__update_claim_table.sql deleted file mode 100644 index a0ac135d93..0000000000 --- a/src/main/resources/db/migration/V043__update_claim_table.sql +++ /dev/null @@ -1,60 +0,0 @@ --- Drop FK constraints -ALTER TABLE claim_party -DROP CONSTRAINT IF EXISTS claim_party_claim_id_fkey; - -ALTER TABLE claim_ground -DROP CONSTRAINT IF EXISTS claim_ground_claim_id_fkey; - -ALTER TABLE enforcement.enf_case -DROP CONSTRAINT IF EXISTS enf_case_claim_id_fkey; - --- Drop old claim table -DROP TABLE IF EXISTS claim; - --- Recreate claim table -CREATE TABLE claim ( - id UUID PRIMARY KEY, - version INT, - case_id uuid references public.pcs_case (id), - claimant_type TEXT, - against_trespassers YES_NO, - due_to_rent_arrears YES_NO, - claim_costs YES_NO, - pre_action_protocol_followed YES_NO, - mediation_attempted YES_NO, - mediation_details VARCHAR(250), - settlement_attempted YES_NO, - settlement_details VARCHAR(250), - claimant_circumstances_provided YES_NO, - claimant_circumstances VARCHAR(950), - additional_defendants YES_NO, - defendant_circumstances_provided YES_NO, - defendant_circumstances VARCHAR(950), - additional_reasons_provided YES_NO, - additional_reasons VARCHAR(6400), - underlessee_or_mortgagee YES_NO, - additional_underlessees_or_mortgagees YES_NO, - additional_docs_provided YES_NO, - gen_app_expected YES_NO, - language_used TEXT -); - --- Re-add FK constraints -ALTER TABLE claim_party - ADD CONSTRAINT claim_party_claim_id_fkey - FOREIGN KEY (claim_id) REFERENCES claim(id); - -ALTER TABLE claim_ground - ADD CONSTRAINT claim_ground_claim_id_fkey - FOREIGN KEY (claim_id) REFERENCES claim(id); - -ALTER TABLE enforcement.enf_case - ADD CONSTRAINT enf_case_claim_id_fkey - FOREIGN KEY (claim_id) REFERENCES claim(id); - --- Drop columns from pcs_case -ALTER TABLE pcs_case - DROP COLUMN mediation_attempted, - DROP COLUMN mediation_attempted_details, - DROP COLUMN settlement_attempted, - DROP COLUMN settlement_attempted_details; diff --git a/src/main/resources/db/migration/V044__add_document_table.sql b/src/main/resources/db/migration/V044__add_document_table.sql deleted file mode 100644 index 017c24b665..0000000000 --- a/src/main/resources/db/migration/V044__add_document_table.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE document ( - id UUID PRIMARY KEY, - case_id UUID REFERENCES pcs_case(id), - url TEXT, - file_name TEXT, - binary_url TEXT, - category_id TEXT, - type TEXT -); - -CREATE TABLE claim_document ( - claim_id UUID REFERENCES claim(id), - document_id UUID REFERENCES document(id), - PRIMARY KEY (claim_id, document_id) -); - -CREATE INDEX idx_document_case_id ON document(case_id); -CREATE INDEX idx_claim_document_claim_id ON claim_document(claim_id); -CREATE INDEX idx_claim_document_document_id ON claim_document(document_id); diff --git a/src/main/resources/db/migration/V045__add_fk_constraint_to_party_access_code.sql b/src/main/resources/db/migration/V045__add_fk_constraint_to_party_access_code.sql deleted file mode 100644 index c9b4d0b611..0000000000 --- a/src/main/resources/db/migration/V045__add_fk_constraint_to_party_access_code.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE party - ADD CONSTRAINT uq_party_id_case UNIQUE (id, case_id); - -ALTER TABLE party_access_code - ADD CONSTRAINT fk_party_access_code_party - FOREIGN KEY (party_id, case_id) - REFERENCES party (id, case_id); - - diff --git a/src/main/resources/db/migration/V046__add_idam_user_id_to_draft_table.sql b/src/main/resources/db/migration/V046__add_idam_user_id_to_draft_table.sql deleted file mode 100644 index a338b4259d..0000000000 --- a/src/main/resources/db/migration/V046__add_idam_user_id_to_draft_table.sql +++ /dev/null @@ -1,18 +0,0 @@ -DROP INDEX IF EXISTS draft.unsubmitted_case_data_case_event_unique_idx; - -ALTER TABLE draft.draft_case_data -ADD COLUMN idam_user_id UUID; - -DELETE FROM draft.draft_case_data; - -ALTER TABLE draft.draft_case_data -ALTER COLUMN idam_user_id SET NOT NULL; - -CREATE UNIQUE INDEX draft_case_data_unique_idx - ON draft.draft_case_data(case_reference, event_id, idam_user_id); - -CREATE INDEX draft_case_data_user_id_idx - ON draft.draft_case_data(idam_user_id); - -CREATE INDEX draft_case_data_case_ref_idx - ON draft.draft_case_data(case_reference); diff --git a/src/main/resources/db/migration/V047__add_defendant_response_table.sql b/src/main/resources/db/migration/V047__add_defendant_response_table.sql deleted file mode 100644 index ca5e62da32..0000000000 --- a/src/main/resources/db/migration/V047__add_defendant_response_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE defendant_response ( - id UUID PRIMARY KEY, - claim_id UUID NOT NULL REFERENCES claim(id), - party_id UUID NOT NULL REFERENCES party(id), - possession_order_type VARCHAR(30) -); diff --git a/src/main/resources/db/migration/V048__claim_related_data.sql b/src/main/resources/db/migration/V048__claim_related_data.sql deleted file mode 100644 index a657a2dd9a..0000000000 --- a/src/main/resources/db/migration/V048__claim_related_data.sql +++ /dev/null @@ -1,48 +0,0 @@ -CREATE TYPE YES_NO_NA AS ENUM ('YES', 'NO', 'NOT_APPLICABLE'); - -CREATE TABLE housing_act_wales ( - id UUID PRIMARY KEY, - version INT, - claim_id UUID REFERENCES claim (id), - registered YES_NO_NA NOT NULL, - registration_number VARCHAR(60), - licensed YES_NO_NA NOT NULL, - licence_number VARCHAR(60), - agent_appointed YES_NO_NA NOT NULL, - agent_first_name VARCHAR(60), - agent_last_name VARCHAR(60), - agent_licence_number VARCHAR(60), - agent_appointment_date DATE -); - -/* -supension_of_rtb = suspension of right to buy -dot = demotion of tenancy -*/ -CREATE TABLE possession_alternatives ( - id UUID PRIMARY KEY, - version INT, - claim_id UUID REFERENCES claim (id), - supension_of_rtb_requested YES_NO NOT NULL, - supension_of_rtb_housing_act_section VARCHAR(20), - supension_of_rtb_reason VARCHAR(250), - dot_requested YES_NO NOT NULL, - dot_housing_act_section VARCHAR(20), - dot_statement_served YES_NO, - dot_statement_details VARCHAR(950), - dot_reason VARCHAR(250) -); - -CREATE TABLE tenancy_licence ( - id UUID PRIMARY KEY, - version INT, - case_id UUID REFERENCES pcs_case (id), - type VARCHAR(40) NOT NULL, - other_type_details VARCHAR(500), - start_date DATE, - rent_amount DECIMAL(18, 2), - rent_frequency VARCHAR(20), - other_rent_frequency VARCHAR(60), - rent_per_day DECIMAL(18, 2), - calculated_daily_rent_correct YES_NO -); diff --git a/src/main/resources/db/migration/V049__add_more_claim_related_tables.sql b/src/main/resources/db/migration/V049__add_more_claim_related_tables.sql deleted file mode 100644 index 58a860c502..0000000000 --- a/src/main/resources/db/migration/V049__add_more_claim_related_tables.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE rent_arrears ( - id UUID PRIMARY KEY, - version INT, - claim_id UUID REFERENCES claim (id), - total_rent_arrears DECIMAL(18, 2) NOT NULL, - third_party_payments_made YES_NO NOT NULL, - arrears_judgment_wanted YES_NO -); - -CREATE TABLE rent_arrears_payment_source ( - id UUID PRIMARY KEY, - version INT, - rent_arrears_id UUID REFERENCES rent_arrears (id), - name VARCHAR(40) NOT NULL, - description VARCHAR(60) -); - -CREATE TABLE notice_of_possession ( - id UUID PRIMARY KEY, - version INT, - claim_id UUID REFERENCES claim (id), - notice_served YES_NO NOT NULL, - notice_type VARCHAR(60), - serving_method VARCHAR(40), - notice_details VARCHAR(250), - notice_date DATE, - notice_date_time TIMESTAMP, - CONSTRAINT chk_notice_date CHECK (notice_date IS NULL OR notice_date_time IS NULL) -); - -CREATE TABLE statement_of_truth ( - id UUID PRIMARY KEY, - version INT, - claim_id UUID REFERENCES claim (id), - completed_by VARCHAR(40) NOT NULL, - accepted YES_NO NOT NULL, - full_name VARCHAR(60) NOT NULL, - firm_name VARCHAR(60), - position_held VARCHAR(60) -); - -ALTER TABLE pcs_case - DROP COLUMN tenancy_licence, - DROP COLUMN statement_of_truth; - diff --git a/src/main/resources/db/migration/V050__recreate_claim_ground_table.sql b/src/main/resources/db/migration/V050__recreate_claim_ground_table.sql deleted file mode 100644 index 3ee0cb1b42..0000000000 --- a/src/main/resources/db/migration/V050__recreate_claim_ground_table.sql +++ /dev/null @@ -1,14 +0,0 @@ -DROP TABLE claim_ground; - -CREATE TABLE claim_ground ( - id UUID PRIMARY KEY, - claim_id UUID NOT NULL REFERENCES claim (id), - category VARCHAR(60), - code VARCHAR(60) NOT NULL, - reason VARCHAR(500), - description VARCHAR(500), - is_rent_arrears BOOLEAN -); - -ALTER TABLE pcs_case - DROP COLUMN possession_grounds; diff --git a/src/main/resources/db/migration/V051__migrate_enforcement_to_public_schema.sql b/src/main/resources/db/migration/V051__migrate_enforcement_to_public_schema.sql deleted file mode 100644 index 3ff53fc603..0000000000 --- a/src/main/resources/db/migration/V051__migrate_enforcement_to_public_schema.sql +++ /dev/null @@ -1,39 +0,0 @@ -ALTER TABLE enforcement.enf_case SET SCHEMA public; - -DO $$ - BEGIN - IF EXISTS ( - SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace - WHERE c.relname = 'enf_case_id_seq' AND n.nspname = 'enforcement' - ) THEN - ALTER SEQUENCE enforcement.enf_case_id_seq SET SCHEMA public; - END IF; - END $$; - -DO $$ - BEGIN - IF NOT EXISTS ( - SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'enf_case' - ) THEN - RAISE EXCEPTION 'Migration failed: enf_case table not found in public schema'; - END IF; - - IF EXISTS ( - SELECT 1 FROM information_schema.tables WHERE table_schema = 'enforcement' AND table_name = 'enf_case' - ) THEN - RAISE EXCEPTION 'Migration failed: enf_case table still exists in enforcement schema'; - END IF; - END $$; - -DROP SCHEMA IF EXISTS enforcement CASCADE; - --- Verify -DO $$ - BEGIN - IF EXISTS ( - SELECT 1 FROM information_schema.schemata - WHERE schema_name = 'enforcement' - ) THEN - RAISE EXCEPTION 'Migration failed: enforcement schema still exists'; - END IF; - END $$; diff --git a/src/main/resources/db/migration/V052__claim_ground_not_null_columns.sql b/src/main/resources/db/migration/V052__claim_ground_not_null_columns.sql deleted file mode 100644 index 114d1c5039..0000000000 --- a/src/main/resources/db/migration/V052__claim_ground_not_null_columns.sql +++ /dev/null @@ -1,6 +0,0 @@ -TRUNCATE claim_ground; - -ALTER TABLE claim_ground - ALTER COLUMN category SET NOT NULL, - ALTER COLUMN is_rent_arrears SET NOT NULL; - diff --git a/src/main/resources/db/migration/V053__address_postcode_length.sql b/src/main/resources/db/migration/V053__address_postcode_length.sql deleted file mode 100644 index 45e2a2f29a..0000000000 --- a/src/main/resources/db/migration/V053__address_postcode_length.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE address - ALTER COLUMN postcode TYPE VARCHAR(14); diff --git a/src/main/resources/db/migration/V054__asb_prohibited_conduct_table.sql b/src/main/resources/db/migration/V054__asb_prohibited_conduct_table.sql deleted file mode 100644 index a4b2e3eef3..0000000000 --- a/src/main/resources/db/migration/V054__asb_prohibited_conduct_table.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE asb_prohibited_conduct ( - id UUID PRIMARY KEY, - version INT, - claim_id UUID UNIQUE REFERENCES claim (id), - antisocial_behaviour YES_NO, - antisocial_behaviour_details VARCHAR(500), - illegal_purposes YES_NO, - illegal_purposes_details VARCHAR(500), - other_prohibited_conduct YES_NO, - other_prohibited_conduct_details VARCHAR(500), - claiming_standard_contract YES_NO, - claiming_standard_contract_details VARCHAR(250), - periodic_contract_agreed YES_NO, - periodic_contract_details VARCHAR(250) -); - diff --git a/src/main/resources/db/migration/V055__create_enf_risk_profile_table.sql b/src/main/resources/db/migration/V055__create_enf_risk_profile_table.sql deleted file mode 100644 index 2b513de307..0000000000 --- a/src/main/resources/db/migration/V055__create_enf_risk_profile_table.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TYPE YES_NO_NOT_SURE AS ENUM ('YES', 'NO', 'NOT_SURE'); - -CREATE TABLE enf_risk_profile ( - id UUID PRIMARY KEY, - enf_case_id UUID NOT NULL REFERENCES enf_case(id) ON DELETE CASCADE, - any_risk_to_bailiff YES_NO_NOT_SURE, - vulnerable_people_present YES_NO_NOT_SURE, - vulnerable_category VARCHAR(100), - vulnerable_reason_text VARCHAR(6800), - violent_details VARCHAR(6800), - firearms_details VARCHAR(6800), - criminal_details VARCHAR(6800), - verbal_threats_details VARCHAR(6800), - protest_group_details VARCHAR(6800), - police_social_services_details VARCHAR(6800), - animals_details VARCHAR(6800), - CONSTRAINT unique_risk_profile_per_case UNIQUE(enf_case_id) -); - -CREATE INDEX idx_enf_risk_profile_case_id ON enf_risk_profile(enf_case_id); diff --git a/src/main/resources/db/migration/V056__enforcement_selected_defendants_schema_table.sql b/src/main/resources/db/migration/V056__enforcement_selected_defendants_schema_table.sql deleted file mode 100644 index 82aae6c744..0000000000 --- a/src/main/resources/db/migration/V056__enforcement_selected_defendants_schema_table.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Selected Defendants (Junction table for selective enforcement) -CREATE TABLE enf_selected_defendants ( - id UUID PRIMARY KEY, - enf_case_id UUID NOT NULL REFERENCES enf_case(id) ON DELETE CASCADE, - party_id UUID NOT NULL REFERENCES party(id), - UNIQUE(enf_case_id, party_id) -); -CREATE INDEX idx_enf_selected_defendants_case ON enf_selected_defendants(enf_case_id); -CREATE INDEX idx_enf_selected_defendants_party ON enf_selected_defendants(party_id); diff --git a/src/main/resources/db/migration/V057__enforcement_warrant_details.sql b/src/main/resources/db/migration/V057__enforcement_warrant_details.sql deleted file mode 100644 index 3af83aa8b1..0000000000 --- a/src/main/resources/db/migration/V057__enforcement_warrant_details.sql +++ /dev/null @@ -1,60 +0,0 @@ -CREATE TYPE STATEMENT_OF_TRUTH_COMPLETED_BY AS ENUM ('CLAIMANT', 'LEGAL_REPRESENTATIVE'); - -CREATE TABLE enf_warrant( - id UUID PRIMARY KEY, - enf_case_id UUID NOT NULL REFERENCES enf_case (id) ON DELETE CASCADE, - - -- UI Control Flags - show_people_who_will_be_evicted_page YES_NO, - show_people_you_want_to_evict_page YES_NO, - - -- Language & Status - is_suspended_order YES_NO, - - -- Additional Information - additional_information_select YES_NO, - additional_information_details VARCHAR(6800), - - -- NameAndAddressForEviction - correct_name_and_address YES_NO, - - -- PeopleToEvict - evict_everyone YES_NO, - - -- PropertyAccessDetails - is_difficult_to_access_property YES_NO, - clarification_on_access_difficulty_text VARCHAR(6800), - - -- Legal Costs & Finances - are_legal_costs_to_be_claimed YES_NO, - amount_of_legal_costs NUMERIC(10, 2), - amount_owed NUMERIC(10, 2), - - -- Land Registry - have_land_registry_fees_been_paid YES_NO, - amount_of_land_registry_fees NUMERIC(10, 2), - - -- Repayment - repayment_choice VARCHAR(20), - amount_of_repayment_costs NUMERIC(10, 2), - repayment_summary_markdown TEXT, - - -- Defendants DOB - defendants_dob_known YES_NO, - defendants_dob_details VARCHAR(6800), - - -- Statement of Truth - completed_by STATEMENT_OF_TRUTH_COMPLETED_BY, - certification TEXT, - agreement_claimant TEXT, - full_name_claimant VARCHAR(60), - position_claimant VARCHAR(60), - agreement_legal_rep TEXT, - full_name_legal_rep VARCHAR(60), - firm_name_legal_rep VARCHAR(60), - position_legal_rep VARCHAR(60), - - CONSTRAINT unique_warrant_per_enforcement UNIQUE (enf_case_id) -); - -CREATE INDEX idx_enf_warrant_case_id ON enf_warrant (enf_case_id); diff --git a/src/main/resources/db/migration/V058__enf_writ_of_restitution_schema_table.sql b/src/main/resources/db/migration/V058__enf_writ_of_restitution_schema_table.sql deleted file mode 100644 index 2e545db81a..0000000000 --- a/src/main/resources/db/migration/V058__enf_writ_of_restitution_schema_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE enf_writ_of_restitution ( - id UUID PRIMARY KEY, - enf_case_id UUID NOT NULL REFERENCES enf_case(id) ON DELETE CASCADE, - CONSTRAINT unique_writ_of_restitution_per_enforcement UNIQUE(enf_case_id) -); -CREATE INDEX idx_enf_writ_of_restitution_case_id ON enf_writ_of_restitution(enf_case_id); diff --git a/src/main/resources/db/migration/V059__enforcement_warrant_of_restitution_table.sql b/src/main/resources/db/migration/V059__enforcement_warrant_of_restitution_table.sql deleted file mode 100644 index 09d5997230..0000000000 --- a/src/main/resources/db/migration/V059__enforcement_warrant_of_restitution_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE enf_warrant_of_restitution ( - id UUID PRIMARY KEY, - enf_case_id UUID NOT NULL REFERENCES enf_case(id) ON DELETE CASCADE, - - CONSTRAINT unique_warrant_of_restitution_per_enforcement UNIQUE(enf_case_id) -); \ No newline at end of file diff --git a/src/main/resources/db/migration/V060__create_contact_preferences_table.sql b/src/main/resources/db/migration/V060__create_contact_preferences_table.sql deleted file mode 100644 index c577650e2b..0000000000 --- a/src/main/resources/db/migration/V060__create_contact_preferences_table.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE public.contact_preferences ( - id UUID PRIMARY KEY, - contact_by_email YES_NO, - contact_by_text YES_NO, - contact_by_post YES_NO, - contact_by_phone YES_NO -); - -ALTER TABLE public.party - ADD COLUMN contact_preferences_id UUID REFERENCES public.contact_preferences (id); \ No newline at end of file diff --git a/src/main/resources/db/migration/V061__add_received_free_legal_advice.sql b/src/main/resources/db/migration/V061__add_received_free_legal_advice.sql deleted file mode 100644 index f8daf0864f..0000000000 --- a/src/main/resources/db/migration/V061__add_received_free_legal_advice.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TYPE YES_NO_PREFER_NOT_TO_SAY AS ENUM ('YES', 'NO', 'PREFER_NOT_TO_SAY'); - -ALTER TABLE defendant_response - ADD COLUMN received_free_legal_advice YES_NO_PREFER_NOT_TO_SAY; diff --git a/src/main/resources/db/migration/V062__enforcement_writ_details.sql b/src/main/resources/db/migration/V062__enforcement_writ_details.sql deleted file mode 100644 index db8acd7a35..0000000000 --- a/src/main/resources/db/migration/V062__enforcement_writ_details.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE enf_writ( - id UUID PRIMARY KEY, - enf_case_id UUID NOT NULL REFERENCES enf_case (id) ON DELETE CASCADE, - - -- NameAndAddressForEviction (JsonUnwrapped) - correct_name_and_address YES_NO, - - -- Direct fields - show_people_who_will_be_evicted_page YES_NO, - has_hired_high_court_enforcement_officer YES_NO, - hceo_details VARCHAR(120), - has_claim_transferred_to_high_court YES_NO, - - -- LandRegistryFees - have_land_registry_fees_been_paid YES_NO, - amount_of_land_registry_fees NUMERIC(10, 2), - - -- LegalCosts - are_legal_costs_to_be_claimed YES_NO, - amount_of_legal_costs NUMERIC(10, 2), - - -- MoneyOwedByDefendants - amount_owed NUMERIC(10, 2), - - CONSTRAINT unique_writ_per_enforcement UNIQUE(enf_case_id) -); - diff --git a/src/main/resources/db/migration/V063__add_tenancy_details.sql b/src/main/resources/db/migration/V063__add_tenancy_details.sql deleted file mode 100644 index 9225350159..0000000000 --- a/src/main/resources/db/migration/V063__add_tenancy_details.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN tenancy_start_date_confirmation YES_NO_NOT_SURE, - ADD COLUMN tenancy_start_date DATE; diff --git a/src/main/resources/db/migration/V064__add_landlord_registered.sql b/src/main/resources/db/migration/V064__add_landlord_registered.sql deleted file mode 100644 index 56d561738e..0000000000 --- a/src/main/resources/db/migration/V064__add_landlord_registered.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN landlord_registered YES_NO_NOT_SURE; diff --git a/src/main/resources/db/migration/V065__add_name_confirmation_to_defendant_response.sql b/src/main/resources/db/migration/V065__add_name_confirmation_to_defendant_response.sql deleted file mode 100644 index f1df538ed2..0000000000 --- a/src/main/resources/db/migration/V065__add_name_confirmation_to_defendant_response.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN defendant_name_confirmation YES_NO; diff --git a/src/main/resources/db/migration/V066__add_date_of_birth_to_party.sql b/src/main/resources/db/migration/V066__add_date_of_birth_to_party.sql deleted file mode 100644 index 17d3850314..0000000000 --- a/src/main/resources/db/migration/V066__add_date_of_birth_to_party.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE party - ADD COLUMN dob DATE; diff --git a/src/main/resources/db/migration/V067__update_defendant_response_table.sql b/src/main/resources/db/migration/V067__update_defendant_response_table.sql deleted file mode 100644 index 90d251bfe0..0000000000 --- a/src/main/resources/db/migration/V067__update_defendant_response_table.sql +++ /dev/null @@ -1,25 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN sot_id UUID UNIQUE REFERENCES statement_of_truth(id), - ADD COLUMN pcs_case_id UUID NOT NULL REFERENCES pcs_case(id), - ADD COLUMN correspondence_address_confirmation YES_NO, - ADD COLUMN possession_notice_received YES_NO_NOT_SURE, - ADD COLUMN notice_received_date DATE, - ADD COLUMN rent_arrears_amount_confirmation YES_NO_NOT_SURE, - ADD COLUMN dispute_claim YES_NO, - ADD COLUMN dispute_claim_details VARCHAR(6800), - ADD COLUMN make_counter_claim YES_NO, - ADD COLUMN version INT, - ADD COLUMN status VARCHAR(60), - ADD COLUMN response_submitted_date TIMESTAMP, - ADD COLUMN response_deleted_date TIMESTAMP, - ADD COLUMN response_received_date TIMESTAMP, - ADD COLUMN language_used TEXT, - ADD COLUMN channel VARCHAR(60), - ADD COLUMN ingestion_source VARCHAR(60), - DROP COLUMN possession_order_type; - --- Rename column must be separate alter statement -ALTER TABLE defendant_response - RENAME COLUMN "received_free_legal_advice" TO free_legal_advice; - -CREATE INDEX defendant_response_pcs_case_idx ON defendant_response (pcs_case_id); diff --git a/src/main/resources/db/migration/V068__create_respond_to_claim_related_tables.sql b/src/main/resources/db/migration/V068__create_respond_to_claim_related_tables.sql deleted file mode 100644 index 82810563f3..0000000000 --- a/src/main/resources/db/migration/V068__create_respond_to_claim_related_tables.sql +++ /dev/null @@ -1,61 +0,0 @@ - --- reasonable_adjustments -CREATE TABLE reasonable_adjustments ( - id UUID PRIMARY KEY, - defendant_response_id UUID NOT NULL UNIQUE REFERENCES defendant_response(id), - reasonable_adjustments_required VARCHAR(250), - reasonable_adjustment_description VARCHAR(500), - hearing_enhancement_description VARCHAR(250), - sign_language_support_description VARCHAR(250), - travel_support_description VARCHAR(250), - welsh_language_requirements VARCHAR(250), - language_interpreter YES_NO, - language_support_description VARCHAR(250), - considered_vulnerable YES_NO, - vulnerable_characteristic_description VARCHAR(250) -); - - --- household_circumstances -CREATE TABLE household_circumstances ( - id UUID PRIMARY KEY, - defendant_response_id UUID NOT NULL UNIQUE REFERENCES defendant_response(id), - dependant_children YES_NO, - dependant_children_details VARCHAR(500), - other_dependants YES_NO, - other_dependant_details VARCHAR(500), - other_tenants YES_NO, - other_tenants_details VARCHAR(500), - alternative_accommodation YES_NO_NOT_SURE, - alternative_accommodation_transfer_date DATE, - share_additional_circumstances YES_NO, - additional_circumstances_details VARCHAR(500), - exceptional_hardship YES_NO, - exceptional_hardship_details VARCHAR(500), - share_income_expense_details YES_NO, - regular_income VARCHAR(60), - universal_credit YES_NO, - uc_application_date DATE, - priority_debts YES_NO, - debt_total DECIMAL(18,2), - debt_contribution DECIMAL(18,2), - debt_contribution_frequency VARCHAR(60), - regular_expenses VARCHAR(500), - expense_amount DECIMAL(18,2), - expense_frequency VARCHAR(60) -); - - --- payment_agreement -CREATE TABLE payment_agreement ( - id UUID PRIMARY KEY, - defendant_response_id UUID NOT NULL UNIQUE REFERENCES defendant_response(id), - any_payments_made YES_NO, - payment_details VARCHAR(500), - paid_money_to_housing_org YES_NO, - repayment_plan_agreed YES_NO_NOT_SURE, - repayment_agreed_details VARCHAR(500), - repay_arrears_instalments YES_NO, - additional_rent_contribution DECIMAL(18,2), - additional_contribution_frequency VARCHAR(50) -); diff --git a/src/main/resources/db/migration/V069__create_party_attribute_assertion_table.sql b/src/main/resources/db/migration/V069__create_party_attribute_assertion_table.sql deleted file mode 100644 index e3d5c60e3d..0000000000 --- a/src/main/resources/db/migration/V069__create_party_attribute_assertion_table.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TYPE party_attribute_assertion_submitted_by AS ENUM ( - 'CLAIMANT', - 'DEFENDANT', - 'JUDGE', - 'COURT_STAFF', - 'CASE_WORKER' -); - -CREATE TYPE party_attribute_assertion_status AS ENUM ( - 'SUBMITTED', - 'UNDER_REVIEW', - 'ACCEPTED', - 'REJECTED' -); - -CREATE TABLE party_attribute_assertion ( - id UUID PRIMARY KEY, - party_id UUID NOT NULL REFERENCES party(id), - evidence_document_id UUID NOT NULL REFERENCES document(id), - attributes_name VARCHAR(255) NOT NULL, - asserted_value TEXT NOT NULL, - asserted_by party_attribute_assertion_submitted_by NOT NULL, - status party_attribute_assertion_status NOT NULL, - created_at TIMESTAMP NOT NULL, - decided_at TIMESTAMP -); - -CREATE INDEX idx_party_attribute_assertion_party_id ON party_attribute_assertion (party_id); - diff --git a/src/main/resources/db/migration/V070__enforcement_data_model_updates.sql b/src/main/resources/db/migration/V070__enforcement_data_model_updates.sql deleted file mode 100644 index 648d921153..0000000000 --- a/src/main/resources/db/migration/V070__enforcement_data_model_updates.sql +++ /dev/null @@ -1,22 +0,0 @@ --- Add Timestamps submission date to each of the existing tables -ALTER TABLE public.enf_warrant ADD COLUMN created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP; -ALTER TABLE public.enf_writ ADD COLUMN created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP; -ALTER TABLE public.enf_warrant_of_restitution ADD COLUMN created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP; -ALTER TABLE public.enf_writ_of_restitution ADD COLUMN created TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP; - --- Add Language used to each existing table -ALTER TABLE public.enf_warrant ADD COLUMN language_used VARCHAR(30); -ALTER TABLE public.enf_writ ADD COLUMN language_used VARCHAR(30); -ALTER TABLE public.enf_warrant_of_restitution ADD COLUMN language_used VARCHAR(30); -ALTER TABLE public.enf_writ_of_restitution ADD COLUMN language_used VARCHAR(30); - -ALTER TABLE public.enf_writ ADD COLUMN repayment_choice VARCHAR(20); -ALTER TABLE public.enf_writ ADD COLUMN amount_of_repayment_costs NUMERIC(10, 2); -ALTER TABLE public.enf_writ ADD COLUMN repayment_summary_markdown TEXT; - --- Not needed within Writ -ALTER TABLE public.enf_writ DROP COLUMN show_people_who_will_be_evicted_page; - -DROP INDEX IF EXISTS idx_enf_writ_of_restitution_case_id; -DROP INDEX IF EXISTS idx_enf_warrant_case_id; -DROP INDEX IF EXISTS idx_enf_selected_defendants_case; diff --git a/src/main/resources/db/migration/V071__add_landlord_licensed_column.sql b/src/main/resources/db/migration/V071__add_landlord_licensed_column.sql deleted file mode 100644 index 9eda4e5734..0000000000 --- a/src/main/resources/db/migration/V071__add_landlord_licensed_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN landlord_licensed YES_NO_NOT_SURE; diff --git a/src/main/resources/db/migration/V072__add_tenancy_type_correct_to_defendant_response.sql b/src/main/resources/db/migration/V072__add_tenancy_type_correct_to_defendant_response.sql deleted file mode 100644 index cb56b0e20c..0000000000 --- a/src/main/resources/db/migration/V072__add_tenancy_type_correct_to_defendant_response.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN tenancy_type_correct YES_NO_NOT_SURE; diff --git a/src/main/resources/db/migration/V073__add_written_terms_column.sql b/src/main/resources/db/migration/V073__add_written_terms_column.sql deleted file mode 100644 index 61662f6284..0000000000 --- a/src/main/resources/db/migration/V073__add_written_terms_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN written_terms YES_NO_NOT_SURE; \ No newline at end of file diff --git a/src/main/resources/db/migration/V074__add_preference_type.sql b/src/main/resources/db/migration/V074__add_preference_type.sql deleted file mode 100644 index 6b56c29538..0000000000 --- a/src/main/resources/db/migration/V074__add_preference_type.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TYPE CONTACT_PREFERENCE_TYPE AS ENUM ('EMAIL', 'POST'); - -ALTER TABLE contact_preferences - ADD COLUMN preference_type CONTACT_PREFERENCE_TYPE, - DROP COLUMN contact_by_email, - DROP COLUMN contact_by_post; diff --git a/src/main/resources/db/migration/V075__alter_statement_of_truth_field_sizes.sql b/src/main/resources/db/migration/V075__alter_statement_of_truth_field_sizes.sql deleted file mode 100644 index 89ad60d853..0000000000 --- a/src/main/resources/db/migration/V075__alter_statement_of_truth_field_sizes.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER TABLE statement_of_truth - ALTER COLUMN full_name TYPE VARCHAR(100), - ALTER COLUMN firm_name TYPE VARCHAR(100), - ALTER COLUMN position_held TYPE VARCHAR(100); - -ALTER TABLE enf_warrant -ALTER COLUMN full_name_claimant TYPE VARCHAR(100), - ALTER COLUMN position_claimant TYPE VARCHAR(100), - ALTER column full_name_legal_rep TYPE VARCHAR(100), - ALTER COLUMN firm_name_legal_rep TYPE VARCHAR(100), - ALTER COLUMN position_legal_rep TYPE VARCHAR(100); \ No newline at end of file diff --git a/src/main/resources/db/migration/V076__create_case_link_and_link_reason_tables.sql b/src/main/resources/db/migration/V076__create_case_link_and_link_reason_tables.sql deleted file mode 100644 index 16c2536a4b..0000000000 --- a/src/main/resources/db/migration/V076__create_case_link_and_link_reason_tables.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE case_link ( - id UUID PRIMARY KEY, - case_id UUID NOT NULL REFERENCES pcs_case(id) ON DELETE CASCADE, - linked_case_reference BIGINT NOT NULL, - ccd_list_id VARCHAR(50), - created_at TIMESTAMP DEFAULT now() -); - -CREATE UNIQUE INDEX ux_case_link_unique - ON case_link(case_id, linked_case_reference); - -CREATE TABLE case_link_reason ( - id UUID PRIMARY KEY, - case_link_id UUID NOT NULL REFERENCES case_link(id) ON DELETE CASCADE, - reason_code VARCHAR(100) NOT NULL -); - -CREATE INDEX idx_case_link_reason_link - ON case_link_reason(case_link_id); diff --git a/src/main/resources/db/migration/V077__general_application.sql b/src/main/resources/db/migration/V077__general_application.sql deleted file mode 100644 index 470a728594..0000000000 --- a/src/main/resources/db/migration/V077__general_application.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE help_with_fees ( - id UUID PRIMARY KEY, - hwf_reference VARCHAR(16) NOT NULL -); - -CREATE TABLE general_application ( - id UUID PRIMARY KEY, - case_id UUID NOT NULL REFERENCES public.pcs_case (id), - sot_id UUID REFERENCES public.statement_of_truth (id), - hwf_id UUID REFERENCES public.help_with_fees (id), - type VARCHAR(50) NOT NULL, - state VARCHAR(30), - party_id UUID NOT NULL REFERENCES public.party (id), - within_14_days YES_NO, - need_hwf YES_NO, - applied_for_hwf YES_NO, - other_parties_agreed YES_NO, - without_notice YES_NO, - without_notice_reason VARCHAR(6800), - what_order_wanted VARCHAR(6800), - documents_uploaded YES_NO, - language_used VARCHAR(30) -); diff --git a/src/main/resources/db/migration/V078__add_description_to_Document_table.sql b/src/main/resources/db/migration/V078__add_description_to_Document_table.sql deleted file mode 100644 index b8dd433dc8..0000000000 --- a/src/main/resources/db/migration/V078__add_description_to_Document_table.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE Document ADD COLUMN description VARCHAR(60); \ No newline at end of file diff --git a/src/main/resources/db/migration/V079__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V079__add_bailiff_date_enf_case.sql deleted file mode 100644 index 75e441cc17..0000000000 --- a/src/main/resources/db/migration/V079__add_bailiff_date_enf_case.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE enf_case - ADD COLUMN bailiff_date timestamp; diff --git a/src/main/resources/db/migration/V080__updating_access_code_column_length.sql b/src/main/resources/db/migration/V080__updating_access_code_column_length.sql deleted file mode 100644 index 5da7b4bbb5..0000000000 --- a/src/main/resources/db/migration/V080__updating_access_code_column_length.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE party_access_code - ALTER COLUMN code TYPE VARCHAR(100); - diff --git a/src/main/resources/db/migration/V081__enforcement_warrant_of_restitution_details.sql b/src/main/resources/db/migration/V081__enforcement_warrant_of_restitution_details.sql deleted file mode 100644 index c5a3e29b5e..0000000000 --- a/src/main/resources/db/migration/V081__enforcement_warrant_of_restitution_details.sql +++ /dev/null @@ -1,20 +0,0 @@ -ALTER TABLE public.document -ADD COLUMN enf_case_id uuid REFERENCES enf_case(id); -CREATE INDEX idx_document_enf_case_id ON document(enf_case_id); - --- Statement of Truth -ALTER TABLE enf_case -ADD COLUMN sot_id uuid REFERENCES statement_of_truth(id); - -ALTER TABLE public.enf_warrant_of_restitution - --- How the defendants returned to the property -ADD COLUMN how_defendants_returned VARCHAR(6800), - --- PropertyAccessDetails -ADD COLUMN is_difficult_to_access_property YES_NO, -ADD COLUMN clarification_on_access_difficulty_text VARCHAR(6800), - --- Additional Information -ADD COLUMN additional_information_select YES_NO, -ADD COLUMN additional_information_details VARCHAR(6800); \ No newline at end of file diff --git a/src/main/resources/db/migration/V082__fee_payment.sql b/src/main/resources/db/migration/V082__fee_payment.sql deleted file mode 100644 index dcce84169b..0000000000 --- a/src/main/resources/db/migration/V082__fee_payment.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE fee_payment ( - id UUID NOT NULL, - claim_id UUID NOT NULL, - party_id UUID, - request_date TIMESTAMP NOT NULL, - request_reference VARCHAR(255), - external_reference VARCHAR(255), - amount NUMERIC(19, 2), - payment_status VARCHAR(50), - - CONSTRAINT pk_fee_payment PRIMARY KEY (id), - CONSTRAINT fk_fee_payment_claim FOREIGN KEY (claim_id) REFERENCES claim (id) -); - -CREATE INDEX idx_fee_payment_request_reference ON fee_payment (request_reference); diff --git a/src/main/resources/db/migration/V083__add_regular_income_fields.sql b/src/main/resources/db/migration/V083__add_regular_income_fields.sql deleted file mode 100644 index 77b4e11baa..0000000000 --- a/src/main/resources/db/migration/V083__add_regular_income_fields.sql +++ /dev/null @@ -1,43 +0,0 @@ -CREATE TYPE income_type AS ENUM ( - 'INCOME_FROM_JOBS', - 'PENSION', - 'UNIVERSAL_CREDIT', - 'OTHER_BENEFITS', - 'MONEY_FROM_ELSEWHERE' -); - -CREATE TYPE recurrence_frequency AS ENUM ( - 'WEEKLY', - 'MONTHLY' -); - -CREATE TABLE regular_income ( - id UUID PRIMARY KEY, - hc_id UUID NOT NULL, - other_income_details VARCHAR(500), - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT fk_regular_income_hc FOREIGN KEY (hc_id) - REFERENCES household_circumstances(id) ON DELETE CASCADE, - CONSTRAINT uq_regular_income_hc UNIQUE (hc_id) -); - -CREATE INDEX idx_regular_income_hc_id ON regular_income(hc_id); - -CREATE TABLE regular_income_item ( - id UUID PRIMARY KEY, - regular_income_id UUID NOT NULL, - income_type income_type NOT NULL, - amount DECIMAL(18,2), - frequency recurrence_frequency, - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT fk_income_item_regular_income FOREIGN KEY (regular_income_id) - REFERENCES regular_income(id) ON DELETE CASCADE, - CONSTRAINT chk_income_item_amount CHECK (amount IS NULL OR amount >= 0), - CONSTRAINT uq_income_item_type UNIQUE (regular_income_id, income_type) -); - -CREATE INDEX idx_income_item_regular_income_id ON regular_income_item(regular_income_id); - -ALTER TABLE household_circumstances DROP COLUMN IF EXISTS regular_income; diff --git a/src/main/resources/db/migration/V084__amend_tenancy_licence_table.sql b/src/main/resources/db/migration/V084__amend_tenancy_licence_table.sql deleted file mode 100644 index c39c0efc5b..0000000000 --- a/src/main/resources/db/migration/V084__amend_tenancy_licence_table.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE tenancy_licence - ADD COLUMN has_copy_of_tenancy_licence YES_NO, - ADD COLUMN reasons_for_no_tenancy_licence VARCHAR(500); diff --git a/src/main/resources/db/migration/V085__add_regular_expenses_table.sql b/src/main/resources/db/migration/V085__add_regular_expenses_table.sql deleted file mode 100644 index b90b1c5145..0000000000 --- a/src/main/resources/db/migration/V085__add_regular_expenses_table.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE regular_expenses( - id UUID PRIMARY KEY, - hc_id UUID NOT NULL REFERENCES household_circumstances(id), - expense_type VARCHAR(30) NOT NULL, - amount DECIMAL(18,2) NOT NULL, - expense_frequency VARCHAR(10) NOT NULL, - CONSTRAINT chk_regular_expense_amount_positive - CHECK (amount >= 0) -); diff --git a/src/main/resources/db/migration/V086__update_contact_preferences_columns.sql b/src/main/resources/db/migration/V086__update_contact_preferences_columns.sql deleted file mode 100644 index 08aaceeef6..0000000000 --- a/src/main/resources/db/migration/V086__update_contact_preferences_columns.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE contact_preferences - ADD COLUMN contact_by_email YES_NO, - ADD COLUMN contact_by_post YES_NO; - - diff --git a/src/main/resources/db/migration/V087__add_other_considerations_to_defendant_response.sql b/src/main/resources/db/migration/V087__add_other_considerations_to_defendant_response.sql deleted file mode 100644 index 65420dd3cf..0000000000 --- a/src/main/resources/db/migration/V087__add_other_considerations_to_defendant_response.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN other_considerations YES_NO, - ADD COLUMN other_considerations_details VARCHAR(6400); diff --git a/src/main/resources/db/migration/V088__create_counter_claim_table.sql b/src/main/resources/db/migration/V088__create_counter_claim_table.sql deleted file mode 100644 index 4bcaf439c4..0000000000 --- a/src/main/resources/db/migration/V088__create_counter_claim_table.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE TABLE counter_claim ( - id UUID PRIMARY KEY, - version INTEGER, - sot_id UUID REFERENCES statement_of_truth(id), - case_id UUID NOT NULL REFERENCES pcs_case(id), - party_id UUID NOT NULL REFERENCES party(id), - claim_type VARCHAR(50), - is_claim_amount_known YES_NO, - claim_amount DECIMAL(18,2), - estimated_max_claim_amount DECIMAL(18,2), - counterclaim_for VARCHAR(6800), - counterclaim_reasons VARCHAR(6800), - other_order_request_details VARCHAR(6800), - other_order_request_facts VARCHAR(6800), - need_help_with_fees YES_NO, - applied_for_hwf YES_NO, - hwf_reference_number VARCHAR(255), - status VARCHAR, - claim_submitted_date TIMESTAMP, - claim_issued_date TIMESTAMP, - last_modified_date TIMESTAMP, - language_used TEXT -); - -ALTER TABLE document ADD COLUMN counter_claim_id UUID REFERENCES counter_claim(id); -CREATE INDEX idx_document_counter_claim_id ON document(counter_claim_id); diff --git a/src/main/resources/db/migration/V089__add_legal_representative_and_legal_representative_claim_party_tables.sql b/src/main/resources/db/migration/V089__add_legal_representative_and_legal_representative_claim_party_tables.sql deleted file mode 100644 index db3509b477..0000000000 --- a/src/main/resources/db/migration/V089__add_legal_representative_and_legal_representative_claim_party_tables.sql +++ /dev/null @@ -1,20 +0,0 @@ -create table legal_representative ( - id uuid primary key, - idam_id UUID, - organisation_name varchar(120), - first_name varchar(60), - last_name varchar(60), - email varchar(120), - phone varchar(40), - address_id UUID REFERENCES address (id) -); - -create table claim_party_legal_representative ( - party_id UUID REFERENCES party (id), - legal_representative_id UUID REFERENCES legal_representative (id), - active YES_NO, - start_date TIMESTAMP WITHOUT TIME ZONE, - end_date TIMESTAMP WITHOUT TIME ZONE, - - primary key (party_id, legal_representative_id) -); diff --git a/src/main/resources/db/migration/V090__create_counter_claim_party_table.sql b/src/main/resources/db/migration/V090__create_counter_claim_party_table.sql deleted file mode 100644 index 6365807f48..0000000000 --- a/src/main/resources/db/migration/V090__create_counter_claim_party_table.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE counter_claim_party ( - id UUID PRIMARY KEY, - cc_id UUID NOT NULL REFERENCES counter_claim(id), - party_id UUID NOT NULL REFERENCES party(id) -); - -CREATE UNIQUE INDEX ux_counter_claim_party - ON counter_claim_party(cc_id, party_id); - -CREATE INDEX idx_counter_claim_party_party_id - ON counter_claim_party(party_id); diff --git a/src/main/resources/db/migration/V091__general_application_dates_and_unique_ref.sql b/src/main/resources/db/migration/V091__general_application_dates_and_unique_ref.sql deleted file mode 100644 index 3652f22a21..0000000000 --- a/src/main/resources/db/migration/V091__general_application_dates_and_unique_ref.sql +++ /dev/null @@ -1,17 +0,0 @@ -ALTER TABLE general_application - ADD COLUMN application_submitted_date TIMESTAMP, - ADD COLUMN application_issued_date TIMESTAMP, - ADD COLUMN client_reference VARCHAR(60); - -CREATE UNIQUE INDEX general_application_case_id_client_ref - ON general_application(case_id, client_reference); - -ALTER TABLE statement_of_truth - ALTER COLUMN completed_by DROP NOT NULL, - ADD COLUMN completed_date TIMESTAMP; - -ALTER TABLE help_with_fees - ALTER COLUMN hwf_reference TYPE VARCHAR(60); - - - diff --git a/src/main/resources/db/migration/V092__fee_payment_amend.sql b/src/main/resources/db/migration/V092__fee_payment_amend.sql deleted file mode 100644 index f0e4661cfa..0000000000 --- a/src/main/resources/db/migration/V092__fee_payment_amend.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE fee_payment - ADD COLUMN hwf_id UUID, - ADD CONSTRAINT fk_fee_payment_help_with_fees FOREIGN KEY (hwf_id) REFERENCES help_with_fees (id); diff --git a/src/main/resources/db/migration/V093__add_document_metadata_fields.sql b/src/main/resources/db/migration/V093__add_document_metadata_fields.sql deleted file mode 100644 index 3a6ef11d70..0000000000 --- a/src/main/resources/db/migration/V093__add_document_metadata_fields.sql +++ /dev/null @@ -1,13 +0,0 @@ -ALTER TABLE document - ADD COLUMN content_type VARCHAR(200), - ADD COLUMN size BIGINT, - ADD COLUMN display_file_name TEXT, - ADD COLUMN claim_id UUID REFERENCES claim(id), - ADD COLUMN defendant_response_id UUID REFERENCES defendant_response(id), - ADD COLUMN party_id UUID REFERENCES party(id), - ADD COLUMN general_application_id UUID REFERENCES general_application(id); - -CREATE INDEX idx_document_claim_id ON document(claim_id); -CREATE INDEX idx_document_defendant_response_id ON document(defendant_response_id); -CREATE INDEX idx_document_party_id ON document(party_id); -CREATE INDEX idx_document_general_application_id ON document(general_application_id); diff --git a/src/main/resources/db/migration/V094__amend_rent_arrears_table.sql b/src/main/resources/db/migration/V094__amend_rent_arrears_table.sql deleted file mode 100644 index e1be881ac8..0000000000 --- a/src/main/resources/db/migration/V094__amend_rent_arrears_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE rent_arrears - ADD COLUMN recovery_attempted YES_NO, - ADD COLUMN recovery_attempt_details VARCHAR(500), - DROP COLUMN third_party_payments_made; - -DROP TABLE rent_arrears_payment_source; diff --git a/src/main/resources/db/migration/V095__add_claim_party_and_gen_app_rank.sql b/src/main/resources/db/migration/V095__add_claim_party_and_gen_app_rank.sql deleted file mode 100644 index d9fefbbbb2..0000000000 --- a/src/main/resources/db/migration/V095__add_claim_party_and_gen_app_rank.sql +++ /dev/null @@ -1,23 +0,0 @@ -/* Add columns without constraints */ -ALTER TABLE claim_party - ADD COLUMN rank INT; - -ALTER TABLE general_application - ADD COLUMN rank INT; - -/* Some unique rank value for any existing test data */ -CREATE TEMPORARY SEQUENCE claim_party_placeholder_rank; -UPDATE claim_party SET rank = nextval('claim_party_placeholder_rank') WHERE rank IS NULL; - -CREATE TEMPORARY SEQUENCE gen_app_placeholder_rank; -UPDATE general_application SET rank = nextval('gen_app_placeholder_rank') WHERE rank IS NULL; - -/* Add constraints */ -ALTER TABLE claim_party - ALTER COLUMN rank SET NOT NULL, - ADD CONSTRAINT uq_claim_role_rank UNIQUE (claim_id, role, rank); - -ALTER TABLE general_application - ALTER COLUMN rank SET NOT NULL, - ADD CONSTRAINT uq_case_party_rank UNIQUE (case_id, party_id, rank); - diff --git a/src/main/resources/db/migration/V096__add_tenancy_type_confirmation_to_defendant_response.sql b/src/main/resources/db/migration/V096__add_tenancy_type_confirmation_to_defendant_response.sql deleted file mode 100644 index 50a41b4898..0000000000 --- a/src/main/resources/db/migration/V096__add_tenancy_type_confirmation_to_defendant_response.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN tenancy_type_confirmation YES_NO_NOT_SURE; diff --git a/src/main/resources/db/migration/V097__drop_tenancy_type_correct_from_defendant_response.sql b/src/main/resources/db/migration/V097__drop_tenancy_type_correct_from_defendant_response.sql deleted file mode 100644 index ede695c5e7..0000000000 --- a/src/main/resources/db/migration/V097__drop_tenancy_type_correct_from_defendant_response.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - DROP COLUMN tenancy_type_correct; diff --git a/src/main/resources/db/migration/V098__amend_claim_table.sql b/src/main/resources/db/migration/V098__amend_claim_table.sql deleted file mode 100644 index d5466320b9..0000000000 --- a/src/main/resources/db/migration/V098__amend_claim_table.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE claim - ADD COLUMN pre_action_protocol_incomplete_explanation VARCHAR(250); diff --git a/src/main/resources/db/migration/V099__drop_mediation_and_settlement_details.sql b/src/main/resources/db/migration/V099__drop_mediation_and_settlement_details.sql deleted file mode 100644 index 66815639a6..0000000000 --- a/src/main/resources/db/migration/V099__drop_mediation_and_settlement_details.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE claim - DROP COLUMN mediation_details, - DROP COLUMN settlement_details; diff --git a/src/main/resources/db/migration/V100__drop_housing_act_wales_table.sql b/src/main/resources/db/migration/V100__drop_housing_act_wales_table.sql deleted file mode 100644 index 6e6d144d66..0000000000 --- a/src/main/resources/db/migration/V100__drop_housing_act_wales_table.sql +++ /dev/null @@ -1,4 +0,0 @@ -DROP TABLE housing_act_wales; - -ALTER TABLE claim - ADD COLUMN is_exempt_landlord YES_NO; diff --git a/src/main/resources/db/migration/V101__add_document_submitted_date.sql b/src/main/resources/db/migration/V101__add_document_submitted_date.sql deleted file mode 100644 index c172752140..0000000000 --- a/src/main/resources/db/migration/V101__add_document_submitted_date.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE document - ADD COLUMN submitted_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP; - -UPDATE document -SET submitted_date = COALESCE(submitted_date, CURRENT_TIMESTAMP); - -ALTER TABLE document - ALTER COLUMN submitted_date SET NOT NULL; diff --git a/src/main/resources/db/migration/V102__add_case_notes.sql b/src/main/resources/db/migration/V102__add_case_notes.sql deleted file mode 100644 index eddb4132ab..0000000000 --- a/src/main/resources/db/migration/V102__add_case_notes.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE public.case_note -( - id UUID PRIMARY KEY, - claim_id UUID NOT NULL REFERENCES public.claim (id), - created_on TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, - created_by VARCHAR(50) NOT NULL, - note VARCHAR(500) NOT NULL -); - -CREATE INDEX idx_case_note_claim_id ON public.case_note(claim_id); \ No newline at end of file diff --git a/src/main/resources/db/migration/V103__add_gen_app_submission_document.sql b/src/main/resources/db/migration/V103__add_gen_app_submission_document.sql deleted file mode 100644 index 94a1bf8cc9..0000000000 --- a/src/main/resources/db/migration/V103__add_gen_app_submission_document.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE general_application - ADD COLUMN submission_document_id UUID REFERENCES document(id); - -ALTER TABLE document - ADD COLUMN document_id UUID; - - diff --git a/src/main/resources/db/migration/V104__create_case_flags_related_tables.sql b/src/main/resources/db/migration/V104__create_case_flags_related_tables.sql deleted file mode 100644 index 076232e7ea..0000000000 --- a/src/main/resources/db/migration/V104__create_case_flags_related_tables.sql +++ /dev/null @@ -1,46 +0,0 @@ -CREATE TABLE flag_ref_data( - id UUID PRIMARY KEY, - flag_code VARCHAR(10), - name VARCHAR(255), - name_cy VARCHAR(255), - hearing_relevant BOOLEAN, - available_externally BOOLEAN, - visibility VARCHAR(20) -); - -CREATE TABLE case_party_flag ( - id UUID PRIMARY KEY, - party_id UUID REFERENCES party(id) ON DELETE CASCADE, - flag_ref_data_id UUID NOT NULL REFERENCES flag_ref_data(id) ON DELETE CASCADE, - sub_type_key VARCHAR(50), - sub_type_value VARCHAR(50), - sub_type_value_cy VARCHAR(50), - other_description VARCHAR(50), - other_description_cy VARCHAR(50), - flag_comment VARCHAR(255), - flag_comment_cy VARCHAR(255), - flag_update_comment VARCHAR(255), - date_time_created TIMESTAMP, - date_time_modified TIMESTAMP, - status VARCHAR(50) NOT NULL, - paths VARCHAR(450) NOT NULL -); - -CREATE TABLE case_flag ( - id UUID PRIMARY KEY, - pcs_case_id UUID NOT NULL REFERENCES pcs_case(id) ON DELETE CASCADE, - flag_ref_data_id UUID NOT NULL REFERENCES flag_ref_data(id) ON DELETE CASCADE, - sub_type_key VARCHAR(50), - sub_type_value VARCHAR(50), - sub_type_value_cy VARCHAR(50), - other_description VARCHAR(50), - other_description_cy VARCHAR(50), - flag_comment VARCHAR(255), - flag_comment_cy VARCHAR(255), - flag_update_comment VARCHAR(255), - date_time_created TIMESTAMP, - date_time_modified TIMESTAMP, - status VARCHAR(50) NOT NULL, - paths VARCHAR(255) NOT NULL -); - diff --git a/src/main/resources/db/migration/V105__add_notice_statement.sql b/src/main/resources/db/migration/V105__add_notice_statement.sql deleted file mode 100644 index 060ff04327..0000000000 --- a/src/main/resources/db/migration/V105__add_notice_statement.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE NOTICE_OF_POSSESSION ADD NOTICE_STATEMENT VARCHAR(500); diff --git a/src/main/resources/db/migration/V106__update_party_attribute_assertation_table.sql b/src/main/resources/db/migration/V106__update_party_attribute_assertation_table.sql deleted file mode 100644 index d402834128..0000000000 --- a/src/main/resources/db/migration/V106__update_party_attribute_assertation_table.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE party_attribute_assertion - RENAME COLUMN decided_at TO last_updated_at; - -ALTER TABLE party_attribute_assertion - ALTER COLUMN evidence_document_id DROP NOT NULL, - ADD COLUMN created_by UUID NOT NULL REFERENCES party(id), - ADD COLUMN last_updated_by UUID NOT NULL REFERENCES party(id); diff --git a/src/main/resources/db/migration/V107__fee_payment_journey_and_task_data.sql b/src/main/resources/db/migration/V107__fee_payment_journey_and_task_data.sql deleted file mode 100644 index 7a8fd1f228..0000000000 --- a/src/main/resources/db/migration/V107__fee_payment_journey_and_task_data.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE fee_payment ADD COLUMN IF NOT EXISTS payment_callback_handler_type VARCHAR(30); -ALTER TABLE fee_payment ADD COLUMN IF NOT EXISTS task_data JSONB; - -UPDATE fee_payment -SET payment_callback_handler_type = 'CLAIM' -WHERE payment_callback_handler_type IS NULL; - -ALTER TABLE fee_payment ALTER COLUMN payment_callback_handler_type SET NOT NULL; diff --git a/src/main/resources/db/migration/V108__update_case_notification.sql b/src/main/resources/db/migration/V108__update_case_notification.sql deleted file mode 100644 index 6e60a866ff..0000000000 --- a/src/main/resources/db/migration/V108__update_case_notification.sql +++ /dev/null @@ -1,21 +0,0 @@ -ALTER TABLE case_notification - RENAME COLUMN notification_id TO id; - -ALTER TABLE case_notification - RENAME CONSTRAINT pk_case_notification TO pk_case_notification_id; - -ALTER TABLE case_notification - ADD COLUMN party_id UUID NOT NULL, - ADD COLUMN claim_id UUID NOT NULL, - ADD COLUMN claim_type VARCHAR(255) NOT NULL; - -ALTER TABLE case_notification - ADD CONSTRAINT fk_case_notification_case - FOREIGN KEY (case_id) - REFERENCES pcs_case (id), - ADD CONSTRAINT fk_case_notification_party - FOREIGN KEY (party_id) - REFERENCES party (id), - ADD CONSTRAINT fk_case_notification_claim - FOREIGN KEY (claim_id) - REFERENCES claim (id); diff --git a/src/main/resources/db/migration/V109__add_claim_submitted_date.sql b/src/main/resources/db/migration/V109__add_claim_submitted_date.sql deleted file mode 100644 index e1cf546ba9..0000000000 --- a/src/main/resources/db/migration/V109__add_claim_submitted_date.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE CLAIM ADD COLUMN claim_submitted_date TIMESTAMP WITH TIME ZONE; diff --git a/src/main/resources/db/migration/V110__truncate_scheduled_tasks.sql b/src/main/resources/db/migration/V110__truncate_scheduled_tasks.sql deleted file mode 100644 index 4557d03069..0000000000 --- a/src/main/resources/db/migration/V110__truncate_scheduled_tasks.sql +++ /dev/null @@ -1,2 +0,0 @@ -/* Truncate scheduled tasks because of change in task data serialisation */ -TRUNCATE scheduled_tasks; diff --git a/src/main/resources/db/migration/V111__create_claim_activity_log_table.sql b/src/main/resources/db/migration/V111__create_claim_activity_log_table.sql deleted file mode 100644 index 07315a7c43..0000000000 --- a/src/main/resources/db/migration/V111__create_claim_activity_log_table.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TYPE claim_activity_type AS ENUM ( - 'DOCUMENTS_CREATED', - 'CLAIMANT_PACK_SENT', - 'DEFENDANT_PACK_SENT' -); - -CREATE TYPE claim_activity_status AS ENUM ( - 'SUCCESS', - 'FAILURE' -); - -CREATE TABLE claim_activity_log ( - id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - case_id UUID NOT NULL REFERENCES pcs_case(id), - party_id UUID REFERENCES party(id), - activity_type claim_activity_type NOT NULL, - status claim_activity_status NOT NULL, - created_at TIMESTAMP NOT NULL DEFAULT now() -); - -CREATE INDEX idx_claim_activity_log_case_id ON claim_activity_log (case_id); - -CREATE INDEX idx_claim_activity_log_party_id ON claim_activity_log (party_id); diff --git a/src/main/resources/db/migration/V112__make_case_notification_ids_nullable.sql b/src/main/resources/db/migration/V112__make_case_notification_ids_nullable.sql deleted file mode 100644 index 5a458acdeb..0000000000 --- a/src/main/resources/db/migration/V112__make_case_notification_ids_nullable.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE case_notification ALTER COLUMN party_id DROP NOT NULL; -ALTER TABLE case_notification ALTER COLUMN claim_id DROP NOT NULL; diff --git a/src/main/resources/db/migration/V113__add_gen_app_party_constraint.sql b/src/main/resources/db/migration/V113__add_gen_app_party_constraint.sql deleted file mode 100644 index f463e47207..0000000000 --- a/src/main/resources/db/migration/V113__add_gen_app_party_constraint.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE general_application - ADD CONSTRAINT fk_general_application_party_case - FOREIGN KEY (party_id, case_id) - REFERENCES party (id, case_id); diff --git a/src/main/resources/db/migration/V114__add_counter_claim_want_to_upload_files_to_defendant_response.sql b/src/main/resources/db/migration/V114__add_counter_claim_want_to_upload_files_to_defendant_response.sql deleted file mode 100644 index e027d19bd8..0000000000 --- a/src/main/resources/db/migration/V114__add_counter_claim_want_to_upload_files_to_defendant_response.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN counter_claim_want_to_upload_files YES_NO; \ No newline at end of file diff --git a/src/main/resources/db/migration/V115__claim_issued_date_to_claim.sql b/src/main/resources/db/migration/V115__claim_issued_date_to_claim.sql deleted file mode 100644 index 6512482f59..0000000000 --- a/src/main/resources/db/migration/V115__claim_issued_date_to_claim.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE claim ADD COLUMN claim_issued_date TIMESTAMP WITH TIME ZONE; - -ALTER TABLE fee_payment RENAME COLUMN payment_status TO status; -ALTER TABLE fee_payment RENAME COLUMN claim_id TO possession_claim_id; - diff --git a/src/main/resources/db/migration/V116__add_party_id_to_draft_table.sql b/src/main/resources/db/migration/V116__add_party_id_to_draft_table.sql deleted file mode 100644 index 0c02a0716d..0000000000 --- a/src/main/resources/db/migration/V116__add_party_id_to_draft_table.sql +++ /dev/null @@ -1,10 +0,0 @@ -DROP INDEX IF EXISTS draft.draft_case_data_unique_idx; - -ALTER TABLE draft.draft_case_data - ADD COLUMN party_id UUID; - -CREATE UNIQUE INDEX draft_case_data_unique_idx - ON draft.draft_case_data(case_reference, event_id, idam_user_id, party_id); - -CREATE INDEX draft_case_data_party_id_idx - ON draft.draft_case_data(party_id); diff --git a/src/main/resources/db/migration/V117__add_organisation_identifier_to_party_and_legal_representative.sql b/src/main/resources/db/migration/V117__add_organisation_identifier_to_party_and_legal_representative.sql deleted file mode 100644 index 70e65b987b..0000000000 --- a/src/main/resources/db/migration/V117__add_organisation_identifier_to_party_and_legal_representative.sql +++ /dev/null @@ -1,8 +0,0 @@ -alter table legal_representative - add column organisation_id varchar(64); - -alter table party - add column organisation_id varchar(64); - -ALTER TABLE defendant_response - ADD CONSTRAINT defendant_response_claim_party UNIQUE (claim_id, party_id); diff --git a/src/main/resources/db/migration/V118__make_case_notification_ids_nullable.sql b/src/main/resources/db/migration/V118__make_case_notification_ids_nullable.sql deleted file mode 100644 index 5a458acdeb..0000000000 --- a/src/main/resources/db/migration/V118__make_case_notification_ids_nullable.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE case_notification ALTER COLUMN party_id DROP NOT NULL; -ALTER TABLE case_notification ALTER COLUMN claim_id DROP NOT NULL; diff --git a/src/main/resources/db/migration/V119__amend_claim_table.sql b/src/main/resources/db/migration/V119__amend_claim_table.sql deleted file mode 100644 index 60fc31af05..0000000000 --- a/src/main/resources/db/migration/V119__amend_claim_table.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE claim - ADD COLUMN energy_performance_certificate_provided YES_NO, - ADD COLUMN gas_safety_report_provided YES_NO, - ADD COLUMN electrical_installation_condition_provided YES_NO, - ADD COLUMN no_energy_performance_certificate_reason VARCHAR(500), - ADD COLUMN no_gas_safety_report_reason VARCHAR(500), - ADD COLUMN no_electrical_installation_condition_reason VARCHAR(500); diff --git a/src/main/resources/db/migration/V120__link_case_note_table_to_pcs_case.sql b/src/main/resources/db/migration/V120__link_case_note_table_to_pcs_case.sql deleted file mode 100644 index f5cb390a0a..0000000000 --- a/src/main/resources/db/migration/V120__link_case_note_table_to_pcs_case.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE case_note - ADD COLUMN case_id UUID REFERENCES pcs_case (id), - ALTER COLUMN claim_id DROP NOT NULL; diff --git a/src/main/resources/db/migration/V121__drop_claim_id_in_case_note_table.sql b/src/main/resources/db/migration/V121__drop_claim_id_in_case_note_table.sql deleted file mode 100644 index 5b619f052c..0000000000 --- a/src/main/resources/db/migration/V121__drop_claim_id_in_case_note_table.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE case_note DROP COLUMN claim_id; diff --git a/src/main/resources/db/migration/V122__update_notice_of_possession.sql b/src/main/resources/db/migration/V122__update_notice_of_possession.sql deleted file mode 100644 index c1ebc5e7f2..0000000000 --- a/src/main/resources/db/migration/V122__update_notice_of_possession.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE NOTICE_OF_POSSESSION ADD UNABLE_TO_UPLOAD_REASON VARCHAR(500); -ALTER TABLE NOTICE_OF_POSSESSION ADD IS_ABLE_TO_UPLOAD_DOCUMENT YES_NO; diff --git a/src/main/resources/db/migration/V123__add_related_entity_id_to_fee_payment.sql b/src/main/resources/db/migration/V123__add_related_entity_id_to_fee_payment.sql deleted file mode 100644 index 9475e7807e..0000000000 --- a/src/main/resources/db/migration/V123__add_related_entity_id_to_fee_payment.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE fee_payment - RENAME COLUMN request_reference to service_request_reference; - -ALTER TABLE fee_payment - ADD COLUMN related_entity_id UUID; diff --git a/src/main/resources/db/migration/V124__add_index_on_claim_party_party_id.sql b/src/main/resources/db/migration/V124__add_index_on_claim_party_party_id.sql deleted file mode 100644 index b923644a9d..0000000000 --- a/src/main/resources/db/migration/V124__add_index_on_claim_party_party_id.sql +++ /dev/null @@ -1,3 +0,0 @@ --- claim_party PK leads on claim_id, so lookups by party_id alone aren't covered. -CREATE INDEX IF NOT EXISTS idx_party_id - ON claim_party (party_id); diff --git a/src/main/resources/db/migration/V125__add_claim_projection_indexes.sql b/src/main/resources/db/migration/V125__add_claim_projection_indexes.sql deleted file mode 100644 index c8deaadd02..0000000000 --- a/src/main/resources/db/migration/V125__add_claim_projection_indexes.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE INDEX IF NOT EXISTS idx_claim_ground_claim_id - ON claim_ground (claim_id); - -CREATE INDEX IF NOT EXISTS idx_notice_of_possession_claim_id - ON notice_of_possession (claim_id); - -CREATE INDEX IF NOT EXISTS idx_possession_alternatives_claim_id - ON possession_alternatives (claim_id); - -CREATE INDEX IF NOT EXISTS idx_rent_arrears_claim_id - ON rent_arrears (claim_id); - -CREATE INDEX IF NOT EXISTS idx_statement_of_truth_claim_id - ON statement_of_truth (claim_id); - -CREATE INDEX IF NOT EXISTS idx_enf_case_claim_id - ON enf_case (claim_id); - -CREATE INDEX IF NOT EXISTS idx_enf_case_sot_id - ON enf_case (sot_id); - -CREATE INDEX IF NOT EXISTS idx_fee_payment_possession_claim_id - ON fee_payment (possession_claim_id); diff --git a/src/main/resources/db/migration/V126__add_case_load_indexes.sql b/src/main/resources/db/migration/V126__add_case_load_indexes.sql deleted file mode 100644 index 180bff682d..0000000000 --- a/src/main/resources/db/migration/V126__add_case_load_indexes.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE INDEX IF NOT EXISTS idx_claim_case_id - ON claim (case_id); - -CREATE INDEX IF NOT EXISTS idx_party_case_id - ON party (case_id); - -CREATE INDEX IF NOT EXISTS idx_tenancy_licence_case_id - ON tenancy_licence (case_id); - -CREATE INDEX IF NOT EXISTS idx_case_note_case_id - ON case_note (case_id); - -CREATE INDEX IF NOT EXISTS idx_case_flag_pcs_case_id - ON case_flag (pcs_case_id); - -CREATE INDEX IF NOT EXISTS idx_case_party_flag_party_id - ON case_party_flag (party_id); diff --git a/src/main/resources/db/migration/V127__fee_payment_unique_service_ref.sql b/src/main/resources/db/migration/V127__fee_payment_unique_service_ref.sql deleted file mode 100644 index f7a70d0191..0000000000 --- a/src/main/resources/db/migration/V127__fee_payment_unique_service_ref.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE fee_payment - ADD CONSTRAINT unique_service_request_ref UNIQUE(service_request_reference) diff --git a/src/main/resources/db/migration/V128__add_claim_form_document.sql b/src/main/resources/db/migration/V128__add_claim_form_document.sql deleted file mode 100644 index 0bb41cd4d4..0000000000 --- a/src/main/resources/db/migration/V128__add_claim_form_document.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE claim - ADD COLUMN claim_form_document_id UUID REFERENCES document(id); - -CREATE INDEX idx_claim_claim_form_document_id ON claim (claim_form_document_id); diff --git a/src/main/resources/db/migration/V129__add_submission_document_to_defendant_response.sql b/src/main/resources/db/migration/V129__add_submission_document_to_defendant_response.sql deleted file mode 100644 index 6fc6659650..0000000000 --- a/src/main/resources/db/migration/V129__add_submission_document_to_defendant_response.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE defendant_response - ADD COLUMN submission_document_id UUID REFERENCES document(id) ON DELETE SET NULL; - -CREATE INDEX idx_defendant_response_submission_document_id - ON defendant_response (submission_document_id); diff --git a/src/main/resources/db/migration/V130__add_column_region_id.sql b/src/main/resources/db/migration/V130__add_column_region_id.sql deleted file mode 100644 index 8e87e7d938..0000000000 --- a/src/main/resources/db/migration/V130__add_column_region_id.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE pcs_case ADD COLUMN region_id INTEGER; -ALTER TABLE pcs_case ADD COLUMN base_location INTEGER; diff --git a/src/main/resources/db/migration/V131__unique_party_access_code_per_party.sql b/src/main/resources/db/migration/V131__unique_party_access_code_per_party.sql deleted file mode 100644 index c2e104f838..0000000000 --- a/src/main/resources/db/migration/V131__unique_party_access_code_per_party.sql +++ /dev/null @@ -1,4 +0,0 @@ --- One access code per party per case: the DB-enforced invariant that stops a defendant getting --- duplicate codes if access-code generation ever runs concurrently for the same party. -ALTER TABLE party_access_code - ADD CONSTRAINT uq_party_access_code_case_party UNIQUE (case_id, party_id); diff --git a/src/main/resources/db/migration/V132__repoint_cf116qx_court_mapping.sql b/src/main/resources/db/migration/V132__repoint_cf116qx_court_mapping.sql deleted file mode 100644 index ace538c682..0000000000 --- a/src/main/resources/db/migration/V132__repoint_cf116qx_court_mapping.sql +++ /dev/null @@ -1,7 +0,0 @@ -UPDATE postcode_court_mapping -SET epims_id = 366572 -WHERE postcode = 'CF116QX'; - -INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) -VALUES (366572, '2025-01-01', '{"created_by": "admin", "change_reason": "repoint CF116QX"}'::jsonb) -ON CONFLICT (epims_id) DO NOTHING; diff --git a/src/main/resources/db/migration/V133__gen_app_case_level_rank.sql b/src/main/resources/db/migration/V133__gen_app_case_level_rank.sql deleted file mode 100644 index 653295f347..0000000000 --- a/src/main/resources/db/migration/V133__gen_app_case_level_rank.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Move GA rank uniqueness from party-level to case-level. --- Drop the old constraint that included party_id. -ALTER TABLE general_application - DROP CONSTRAINT IF EXISTS uq_case_party_rank; - --- Re-number any existing rows so that the first GA per case is rank 1, the second is rank 2, etc. -WITH renumbered AS ( - SELECT id, - ROW_NUMBER() OVER (PARTITION BY case_id ORDER BY application_submitted_date NULLS LAST, id) AS new_rank - FROM general_application -) -UPDATE general_application ga -SET rank = r.new_rank - FROM renumbered r -WHERE ga.id = r.id; - --- Add the new case-level unique constraint. -ALTER TABLE general_application - ADD CONSTRAINT uq_general_application_case_rank UNIQUE (case_id, rank); diff --git a/src/main/resources/db/migration/V134__claim_activity_log_pack_tracking.sql b/src/main/resources/db/migration/V134__claim_activity_log_pack_tracking.sql deleted file mode 100644 index 43755601c5..0000000000 --- a/src/main/resources/db/migration/V134__claim_activity_log_pack_tracking.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Pack-grained dispatch outcomes on claim_activity_log. The log stores events only - --- document relationships stay in the document table and its owners --- (claim.claim_form_document_id, defendant_response.submission_document_id, document.party_id). --- --- DOCUMENTS_CREATED : generation outcome per party; FAILURE rows carry --- GenerationDetails {documentType, failureReason, terminal} in details --- PACK_SENT / PACK_FAILED : one row per (recipient, pack) dispatch, with PackDetails --- {packType, documents:[{id,type}], failureReason, terminal} in details -ALTER TABLE claim_activity_log ADD COLUMN details JSONB; - --- Store activity_type/status as plain VARCHAR: the value sets are owned by the Java enums --- (ClaimActivityType, ClaimActivityStatus), so adding/removing values is a code-only change - --- no Postgres enum-type recreation dances. Drops the superseded pack-sent values with the type. -ALTER TABLE claim_activity_log ALTER COLUMN activity_type TYPE VARCHAR USING activity_type::text; -ALTER TABLE claim_activity_log ALTER COLUMN status TYPE VARCHAR USING status::text; -DROP TYPE claim_activity_type; -DROP TYPE claim_activity_status; - -CREATE INDEX IF NOT EXISTS idx_claim_activity_log_type_status ON claim_activity_log (activity_type, status); diff --git a/src/main/resources/db/migration/V135__default_uncategorised_document_category.sql b/src/main/resources/db/migration/V135__default_uncategorised_document_category.sql deleted file mode 100644 index 496ee14494..0000000000 --- a/src/main/resources/db/migration/V135__default_uncategorised_document_category.sql +++ /dev/null @@ -1,9 +0,0 @@ -UPDATE document -SET category_id = 'uncategorisedDocuments' -WHERE category_id IS NULL; - -ALTER TABLE document -ALTER COLUMN category_id SET DEFAULT 'uncategorisedDocuments'; - -ALTER TABLE document -ALTER COLUMN category_id SET NOT NULL; diff --git a/src/main/resources/db/testdata/V001.1__test_data.sql b/src/main/resources/db/testdata/V001.1__test_data.sql new file mode 100644 index 0000000000..3269183472 --- /dev/null +++ b/src/main/resources/db/testdata/V001.1__test_data.sql @@ -0,0 +1,110 @@ +-- HDPI-7834: consolidated test data (merged from the former V001.1-V001.9) +-- Order preserved - later sections update rows inserted by earlier ones. + +-- ===== from V001.1__postcode_test_data.sql ===== +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) VALUES + ('W3 7RX', 20262, 'England', '2025-01-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('W3 6RS', 36791, 'England', '2025-02-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('M13 9PL', 144641, 'England', '2025-04-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('LE2 0QB', 425094, 'England', '2023-04-01', '2024-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('UB7 0DG', 28837, 'England', '2026-04-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('SW4 7R', 36791, 'England', '2025-05-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('W5 7', 144641, 'England', '2025-05-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('UB2', 20262, 'England', '2025-05-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('SW1 1AA', 817113, 'England', '2025-06-16', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('SW1 1AA', 817114, 'England', '2025-06-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('W95', 20263, 'England', '2025-06-01', '2025-06-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('W95', 20262, 'England', '2025-06-11', '2035-07-31', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('DN5 51P', 999985, 'England', '2025-06-01', '2035-11-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('DN5 51P', 999984, 'England', '2025-01-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('SL6', 144641, 'England', '2025-06-01', '2035-11-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('M13 9PZ', 817114, 'England', '2025-01-01', '2025-02-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('M13 9P', 484482, 'England', '2025-03-01', '2025-04-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('M13 9', 20262, 'England', '2025-06-01', '2035-07-31', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('M13', 144641, 'England', '2025-06-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('RG6 1JS', 814567, 'England', '2025-03-01', '2025-04-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb); + + + +-- ===== from V001.2__court_eligibility_test_data.sql ===== +INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) VALUES + (20262, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb), + (28837, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb), + (144641, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb), + (425094, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb); + +-- ===== from V001.3__update_eligibility_dates_to_current.sql ===== +-- HDPI-1256: Update eligibility_whitelisted_epim test data to use current dates +-- This updates the hardcoded dates to current date for eligibility and current timestamp for audit + +UPDATE eligibility_whitelisted_epim +SET + eligible_from = CURRENT_DATE, + audit = jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')) +WHERE epims_id IN (20262, 28837, 144641, 425094); +-- ===== from V001.4__update_postcode_test_data_with_crossborder_postcodes.sql ===== +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) VALUES + ('SY132LH', 20262, 'England', '2025-06-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), + ('SY132LH', 28837, 'Wales', '2025-03-01', '2035-04-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb); + + + +-- ===== from V001.5__add_scotland_ni_iom_channel_islands_postcodes.sql ===== +-- Add postcode mappings for Scotland, Northern Ireland, Isle of Man, and Channel Islands +-- HDPI-1269: Handling Scotland, Northern Ireland, Channel Islands & IoM postcodes + +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) +VALUES + -- Northern Ireland postcodes + ('BT8', 99991, 'Northern Ireland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + ('BT93', 99992, 'Northern Ireland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + + -- Channel Islands postcodes + ('JE3', 99993, 'Channel Islands', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + ('GY10', 99994, 'Channel Islands', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + + -- Isle of Man postcodes + ('IM1', 99995, 'Isle of Man', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + + -- Scotland postcodes (additional to existing TD1) + ('AB10', 99996, 'Scotland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + + -- Cross-border postcode TD1 (already exists but ensuring consistency) + ('TD1', 99997, 'Scotland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), + ('TD1', 99998, 'England', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))); + + + +-- ===== from V001.6__add_postcodes_for_local_test_address.sql ===== +/* Insert the postcode used by the fake address lookup when running locally with CftLib */ +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) VALUES + ('SW111PD', 20264, 'England', '2025-01-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb); + +INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) VALUES + (20264, '2025-01-01', '{"generated, R1, V1": "2025-09-01T08:00:00.000Z"}'::jsonb); + +-- ===== from V001.7__add_wales_postcodes_and_courts.sql ===== +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) +VALUES ('CF116QX', 30100, 'Wales', '2025-08-29', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'); + +INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) VALUES + (30100, '2025-01-01', '{"generated, R1, V1": "2025-09-01T08:00:00.000Z"}'::jsonb); + +-- ===== from V001.8__add_england_wales_nocourt_postcodes.sql ===== +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) +VALUES ('SY45NN', 11111, 'England', '2025-08-29', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'); +INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) +VALUES ('SY45NN', 22222, 'Wales', '2025-08-29', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'); + +-- ===== from V001.9__update_epim_test_data.sql ===== +UPDATE postcode_court_mapping SET epims_id = 20262 WHERE postcode = 'CF116QX'; + +-- ===== from V132__repoint_cf116qx_court_mapping.sql (was a MIGRATION on master; its +-- reference-data change must survive the baseline consolidation on preview/local) ===== +UPDATE postcode_court_mapping +SET epims_id = 366572 +WHERE postcode = 'CF116QX'; + +INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) +VALUES (366572, '2025-01-01', '{"created_by": "admin", "change_reason": "repoint CF116QX"}'::jsonb) +ON CONFLICT (epims_id) DO NOTHING; diff --git a/src/main/resources/db/testdata/V002.1__postcode_test_data.sql b/src/main/resources/db/testdata/V002.1__postcode_test_data.sql deleted file mode 100644 index 87f7bffe74..0000000000 --- a/src/main/resources/db/testdata/V002.1__postcode_test_data.sql +++ /dev/null @@ -1,23 +0,0 @@ -INSERT INTO postcode_court_mapping (postcode, epimid, legislative_country, effective_from, effective_to, audit) VALUES - ('W3 7RX', 20262, 'England', '2025-01-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('W3 6RS', 36791, 'England', '2025-02-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('M13 9PL', 144641, 'England', '2025-04-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('LE2 0QB', 425094, 'England', '2023-04-01', '2024-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('UB7 0DG', 28837, 'England', '2026-04-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('SW4 7R', 36791, 'England', '2025-05-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('W5 7', 144641, 'England', '2025-05-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('UB2', 20262, 'England', '2025-05-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('SW1 1AA', 817113, 'England', '2025-06-16', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('SW1 1AA', 817114, 'England', '2025-06-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('W95', 20263, 'England', '2025-06-01', '2025-06-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('W95', 20262, 'England', '2025-06-11', '2035-07-31', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('DN5 51P', 999985, 'England', '2025-06-01', '2035-11-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('DN5 51P', 999984, 'England', '2025-01-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('SL6', 144641, 'England', '2025-06-01', '2035-11-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('M13 9PZ', 817114, 'England', '2025-01-01', '2025-02-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('M13 9P', 484482, 'England', '2025-03-01', '2025-04-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('M13 9', 20262, 'England', '2025-06-01', '2035-07-31', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('M13', 144641, 'England', '2025-06-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('RG6 1JS', 814567, 'England', '2025-03-01', '2025-04-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb); - - diff --git a/src/main/resources/db/testdata/V008.1__court_eligibility_test_data.sql b/src/main/resources/db/testdata/V008.1__court_eligibility_test_data.sql deleted file mode 100644 index 3f1e482ebf..0000000000 --- a/src/main/resources/db/testdata/V008.1__court_eligibility_test_data.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) VALUES - (20262, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb), - (28837, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb), - (144641, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb), - (425094, '2025-07-14', '{"generated, R1, V1": "2025-07-08T10:02:39.968Z"}'::jsonb); diff --git a/src/main/resources/db/testdata/V008.2__update_eligibility_dates_to_current.sql b/src/main/resources/db/testdata/V008.2__update_eligibility_dates_to_current.sql deleted file mode 100644 index ff7aca1e22..0000000000 --- a/src/main/resources/db/testdata/V008.2__update_eligibility_dates_to_current.sql +++ /dev/null @@ -1,8 +0,0 @@ --- HDPI-1256: Update eligibility_whitelisted_epim test data to use current dates --- This updates the hardcoded dates to current date for eligibility and current timestamp for audit - -UPDATE eligibility_whitelisted_epim -SET - eligible_from = CURRENT_DATE, - audit = jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')) -WHERE epims_id IN (20262, 28837, 144641, 425094); \ No newline at end of file diff --git a/src/main/resources/db/testdata/V010.1__update_postcode_test_data_with_crossborder_postcodes.sql b/src/main/resources/db/testdata/V010.1__update_postcode_test_data_with_crossborder_postcodes.sql deleted file mode 100644 index 680d9818b6..0000000000 --- a/src/main/resources/db/testdata/V010.1__update_postcode_test_data_with_crossborder_postcodes.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) VALUES - ('SY132LH', 20262, 'England', '2025-06-01', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb), - ('SY132LH', 28837, 'Wales', '2025-03-01', '2035-04-10', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb); - - diff --git a/src/main/resources/db/testdata/V010.2__add_scotland_ni_iom_channel_islands_postcodes.sql b/src/main/resources/db/testdata/V010.2__add_scotland_ni_iom_channel_islands_postcodes.sql deleted file mode 100644 index 5daaa9873c..0000000000 --- a/src/main/resources/db/testdata/V010.2__add_scotland_ni_iom_channel_islands_postcodes.sql +++ /dev/null @@ -1,24 +0,0 @@ --- Add postcode mappings for Scotland, Northern Ireland, Isle of Man, and Channel Islands --- HDPI-1269: Handling Scotland, Northern Ireland, Channel Islands & IoM postcodes - -INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) -VALUES - -- Northern Ireland postcodes - ('BT8', 99991, 'Northern Ireland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - ('BT93', 99992, 'Northern Ireland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - - -- Channel Islands postcodes - ('JE3', 99993, 'Channel Islands', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - ('GY10', 99994, 'Channel Islands', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - - -- Isle of Man postcodes - ('IM1', 99995, 'Isle of Man', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - - -- Scotland postcodes (additional to existing TD1) - ('AB10', 99996, 'Scotland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - - -- Cross-border postcode TD1 (already exists but ensuring consistency) - ('TD1', 99997, 'Scotland', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))), - ('TD1', 99998, 'England', CURRENT_DATE, NULL, jsonb_build_object('generated, R1, V1', to_char(NOW(), 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"'))); - - diff --git a/src/main/resources/db/testdata/V017.1__add_postcodes_for_local_test_address.sql b/src/main/resources/db/testdata/V017.1__add_postcodes_for_local_test_address.sql deleted file mode 100644 index 9d36231498..0000000000 --- a/src/main/resources/db/testdata/V017.1__add_postcodes_for_local_test_address.sql +++ /dev/null @@ -1,6 +0,0 @@ -/* Insert the postcode used by the fake address lookup when running locally with CftLib */ -INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) VALUES - ('SW111PD', 20264, 'England', '2025-01-01', '2035-04-01', '{"created_by": "admin", "change_reason": "initial insert"}'::jsonb); - -INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) VALUES - (20264, '2025-01-01', '{"generated, R1, V1": "2025-09-01T08:00:00.000Z"}'::jsonb); diff --git a/src/main/resources/db/testdata/V017.2__add_wales_postcodes_and_courts.sql b/src/main/resources/db/testdata/V017.2__add_wales_postcodes_and_courts.sql deleted file mode 100644 index 5fb431a7ec..0000000000 --- a/src/main/resources/db/testdata/V017.2__add_wales_postcodes_and_courts.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) -VALUES ('CF116QX', 30100, 'Wales', '2025-08-29', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'); - -INSERT INTO eligibility_whitelisted_epim (epims_id, eligible_from, audit) VALUES - (30100, '2025-01-01', '{"generated, R1, V1": "2025-09-01T08:00:00.000Z"}'::jsonb); diff --git a/src/main/resources/db/testdata/V018.1__add_england_wales_nocourt_postcodes.sql b/src/main/resources/db/testdata/V018.1__add_england_wales_nocourt_postcodes.sql deleted file mode 100644 index 56b7e471f1..0000000000 --- a/src/main/resources/db/testdata/V018.1__add_england_wales_nocourt_postcodes.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) -VALUES ('SY45NN', 11111, 'England', '2025-08-29', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'); -INSERT INTO postcode_court_mapping (postcode, epims_id, legislative_country, effective_from, effective_to, audit) -VALUES ('SY45NN', 22222, 'Wales', '2025-08-29', NULL, '{"created_by": "admin", "change_reason": "initial insert"}'); diff --git a/src/main/resources/db/testdata/V019.1__update_epim_test_data.sql b/src/main/resources/db/testdata/V019.1__update_epim_test_data.sql deleted file mode 100644 index 40f0426874..0000000000 --- a/src/main/resources/db/testdata/V019.1__update_epim_test_data.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE postcode_court_mapping SET epims_id = 20262 WHERE postcode = 'CF116QX'; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/CaseLinkServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/CaseLinkServiceTest.java index d1906c8168..eb8b676636 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/CaseLinkServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/CaseLinkServiceTest.java @@ -71,7 +71,7 @@ private CaseLinkReasonEntity createCaseLinkReasonEntity() { private CaseLinkEntity createCaseLinkEntity(List linkReasonEntities) { return CaseLinkEntity.builder() - .id(UUID.randomUUID()) + .id(1) .linkedCaseReference(1234L) .ccdListId("PCS") .reasons(linkReasonEntities) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java index f9b6252f88..b4cbded1a8 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java @@ -1184,7 +1184,7 @@ void shouldScheduleDefenceFormGenerationOnCitizenPath() { stubClaimLookup(); UUID partyId = UUID.randomUUID(); when(partyEntity.getId()).thenReturn(partyId); - UUID responseId = UUID.randomUUID(); + Integer responseId = 1; when(defendantResponseRepository.save(any(DefendantResponseEntity.class))) .thenReturn(DefendantResponseEntity.builder().id(responseId).party(partyEntity).build()); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java index b257dcc52b..e5a2d45d1e 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java @@ -580,7 +580,7 @@ private CaseLinkReasonEntity createCaseLinkReasonEntity() { private CaseLinkEntity createCaseLinkEntity(List linkReasonEntities) { return CaseLinkEntity.builder() - .id(UUID.randomUUID()) + .id(1) .linkedCaseReference(CASE_REFERENCE) .ccdListId("PCS") .reasons(linkReasonEntities) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/bulkprint/SentPackDocumentsTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/bulkprint/SentPackDocumentsTest.java index d255473549..d803bcfb37 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/bulkprint/SentPackDocumentsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/bulkprint/SentPackDocumentsTest.java @@ -94,7 +94,7 @@ void shouldBuildCompositeKey() { private ClaimActivityLogEntity packRow(PartyEntity party, ClaimActivityType activityType, ClaimActivityStatus status, String details) { return ClaimActivityLogEntity.builder() - .id(UUID.randomUUID()) + .id(1) .party(party) .activityType(activityType) .status(status) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPayloadBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPayloadBuilderTest.java index 3c7f315a82..2e46bfea16 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPayloadBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPayloadBuilderTest.java @@ -691,7 +691,7 @@ private static DefendantResponseEntity response(LegislativeCountry country) { claim.getClaimParties().add(claimParty(claim, defendant, PartyRole.DEFENDANT, 1)); return DefendantResponseEntity.builder() - .id(UUID.randomUUID()) + .id(1) .claim(claim) .pcsCase(pcsCase) .party(defendant) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceServiceTest.java index e447cfbc5c..28b2c7cd1c 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormPersistenceServiceTest.java @@ -36,7 +36,7 @@ class DefenceFormPersistenceServiceTest { private static final long CASE_REFERENCE = 1234567812345678L; - private static final UUID RESPONSE_ID = UUID.randomUUID(); + private static final Integer RESPONSE_ID = 1; private static final String DM_STORE_URL = "https://dm-store/xyz"; @Mock diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormSchedulerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormSchedulerTest.java index 72ed08042b..b15867907d 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormSchedulerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormSchedulerTest.java @@ -21,7 +21,7 @@ class DefenceFormSchedulerTest { private static final long CASE_REFERENCE = 1234567812345678L; - private static final UUID RESPONSE_ID = UUID.randomUUID(); + private static final Integer RESPONSE_ID = 1; private static final UUID PARTY_ID = UUID.randomUUID(); @Mock diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormServiceTest.java index 0afdf89224..720cf1ad0f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/defenceform/DefenceFormServiceTest.java @@ -10,7 +10,6 @@ import uk.gov.hmcts.reform.pcs.document.model.defenceform.DefenceFormPayload; import java.util.Optional; -import java.util.UUID; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; @@ -26,7 +25,7 @@ @ExtendWith(MockitoExtension.class) class DefenceFormServiceTest { - private static final UUID RESPONSE_ID = UUID.randomUUID(); + private static final Integer RESPONSE_ID = 1; private static final String DM_STORE_URL = "https://dm-store/xyz"; @Mock diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/document/DocumentServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/document/DocumentServiceTest.java index 91314aa40e..5c5bcd63dd 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/document/DocumentServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/document/DocumentServiceTest.java @@ -731,7 +731,7 @@ void shouldSaveDefendantEvidenceDocuments() { DefendantResponseEntity response = mock(DefendantResponseEntity.class); PcsCaseEntity pcsCase = mock(PcsCaseEntity.class); PartyEntity party = mock(PartyEntity.class); - when(response.getId()).thenReturn(UUID.randomUUID()); + when(response.getId()).thenReturn(1); setUpDefendantParty(pcsCase, party, 2); UploadedDocument defDoc1 = UploadedDocument.builder() @@ -854,7 +854,7 @@ void shouldFilterOutNullValuesFromDefendantEvidenceDocuments() { DefendantResponseEntity response = mock(DefendantResponseEntity.class); PcsCaseEntity pcsCase = mock(PcsCaseEntity.class); PartyEntity party = mock(PartyEntity.class); - when(response.getId()).thenReturn(UUID.randomUUID()); + when(response.getId()).thenReturn(1); setUpDefendantParty(pcsCase, party, 1); UploadedDocument validDoc = UploadedDocument.builder() @@ -889,7 +889,7 @@ void shouldSaveDefendantEvidenceWithNullMetadata() { DefendantResponseEntity response = mock(DefendantResponseEntity.class); PcsCaseEntity pcsCase = mock(PcsCaseEntity.class); PartyEntity party = mock(PartyEntity.class); - when(response.getId()).thenReturn(UUID.randomUUID()); + when(response.getId()).thenReturn(1); setUpDefendantParty(pcsCase, party, 1); UploadedDocument defDoc = UploadedDocument.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/enforcetheorder/strategy/WarrantStrategyTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/enforcetheorder/strategy/WarrantStrategyTest.java index 52d5939c44..92328a1f6f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/enforcetheorder/strategy/WarrantStrategyTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/enforcetheorder/strategy/WarrantStrategyTest.java @@ -96,7 +96,7 @@ void shouldProcessWarrantDetailsAndSaveToRepository() { // Given WarrantEntity warrantEntity = new WarrantEntity(); WarrantEntity savedWarrantEntity = new WarrantEntity(); - savedWarrantEntity.setId(UUID.randomUUID()); + savedWarrantEntity.setId(1); when(warrantDetailsMapper.toEntity(enforcementOrder, enforcementOrderEntity)) .thenReturn(warrantEntity); @@ -118,7 +118,7 @@ void shouldSetSavedWarrantDetailsOnEnforcementOrderEntity() { // Given WarrantEntity warrantEntity = new WarrantEntity(); WarrantEntity savedWarrantEntity = new WarrantEntity(); - UUID warrantId = UUID.randomUUID(); + Integer warrantId = 1; savedWarrantEntity.setId(warrantId); when(warrantDetailsMapper.toEntity(enforcementOrder, enforcementOrderEntity)) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefenceFormGenerationComponentTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefenceFormGenerationComponentTest.java index 6a03027509..920d6667ca 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefenceFormGenerationComponentTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefenceFormGenerationComponentTest.java @@ -42,7 +42,7 @@ @ExtendWith(MockitoExtension.class) class DefenceFormGenerationComponentTest { - private static final UUID RESPONSE_ID = UUID.randomUUID(); + private static final Integer RESPONSE_ID = 1; private static final UUID PARTY_ID = UUID.randomUUID(); private DefenceFormGenerationComponent component; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponentTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponentTest.java index 061ac204a9..ea9bc6106c 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponentTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/DefendantResponseSubmittedNotificationTaskComponentTest.java @@ -14,7 +14,6 @@ import uk.gov.hmcts.reform.pcs.notify.service.DefendantResponseNotificationService; import java.time.Duration; -import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -61,7 +60,7 @@ void shouldCreateTaskDescriptorWithCorrectNameAndType() { @Test @DisplayName("Should send notification when task executes") void shouldSendNotificationWhenTaskExecutes() { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; DefendantResponseStatusChangeTaskData taskData = DefendantResponseStatusChangeTaskData.builder() .defendantResponseId(defendantResponseId) .build(); @@ -79,7 +78,7 @@ void shouldSendNotificationWhenTaskExecutes() { @Test @DisplayName("Should rethrow exception when notification service fails") void shouldRethrowExceptionWhenNotificationServiceFails() { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; DefendantResponseStatusChangeTaskData taskData = DefendantResponseStatusChangeTaskData.builder() .defendantResponseId(defendantResponseId) .build(); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponentTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponentTest.java index 617a6f7d69..c555f0b69d 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponentTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/task/FeePaymentPaidNotificationTaskComponentTest.java @@ -14,7 +14,6 @@ import uk.gov.hmcts.reform.pcs.notify.service.FeePaymentNotificationService; import java.time.Duration; -import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; @@ -59,7 +58,7 @@ void shouldCreateTaskDescriptorWithCorrectNameAndType() { @Test @DisplayName("Should send notification") void shouldSendNotification() { - UUID feePaymentId = UUID.randomUUID(); + Integer feePaymentId = 1; FeePaymentStatusChangeTaskData taskData = FeePaymentStatusChangeTaskData.builder() .feePaymentId(feePaymentId) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/config/NotificationErrorHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/config/NotificationErrorHandlerTest.java index 7f778a0e7e..c566b0c36d 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/config/NotificationErrorHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/config/NotificationErrorHandlerTest.java @@ -43,7 +43,7 @@ void setUp() { errorHandler = new NotificationErrorHandler(); mockCaseNotification = new CaseNotification(); - mockCaseNotification.setId(UUID.randomUUID()); + mockCaseNotification.setId(1); mockCaseNotification.setRecipient("test@example.com"); mockCaseNotification.setType(NotificationType.EMAIL); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListenerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListenerTest.java index 7b7de65841..4c63695008 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListenerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/DefendantResponseEntityListenerTest.java @@ -14,8 +14,6 @@ import uk.gov.hmcts.reform.pcs.ccd.model.DefendantResponseStatusChangeTaskData; import uk.gov.hmcts.reform.pcs.ccd.task.DefendantResponseSubmittedNotificationTaskComponent; -import java.util.UUID; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -44,7 +42,7 @@ void shouldSetPreviousStatusOnPostLoad() { @Test void shouldScheduleNotificationOnPostPersistWhenStatusIsSubmitted() { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; DefendantResponseEntity entity = mock(DefendantResponseEntity.class); when(entity.getStatus()).thenReturn(DefendantResponseStatus.SUBMITTED); when(entity.getId()).thenReturn(defendantResponseId); @@ -86,7 +84,7 @@ void shouldDoNothingOnPostUpdateWhenStatusHasNotChanged() { @Test void shouldScheduleNotificationOnPostUpdateWhenStatusChangesToSubmitted() { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; DefendantResponseEntity entity = mock(DefendantResponseEntity.class); when(entity.getStatus()).thenReturn(DefendantResponseStatus.SUBMITTED); when(entity.getPreviousStatus()).thenReturn(DefendantResponseStatus.CREATED); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListenerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListenerTest.java index d8bbb0e4bc..bbc50b439a 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListenerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/listener/FeePaymentEntityListenerTest.java @@ -57,7 +57,7 @@ void setUp() { party.setClaimParties(Set.of(claimParty)); feePaymentEntity = FeePaymentEntity.builder() - .id(UUID.randomUUID()) + .id(1) .claim(claim) .party(party) .paymentStatus(PaymentStatus.NOT_PAID) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationServiceTest.java index 43509667f0..0314281313 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/DefendantResponseNotificationServiceTest.java @@ -49,7 +49,7 @@ void setUp() { @Test void shouldThrowExceptionWhenDefendantResponseNotFound() { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; when(defendantResponseRepository.findById(defendantResponseId)) .thenReturn(Optional.empty()); @@ -64,7 +64,7 @@ void shouldThrowExceptionWhenDefendantResponseNotFound() { void shouldSendDefendantResponseReceivedEmail() { DefendantResponseEntity response = mock(DefendantResponseEntity.class); ClaimEntity claim = mock(ClaimEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; when(defendantResponseRepository.findById(defendantResponseId)) .thenReturn(Optional.of(response)); @@ -81,7 +81,7 @@ void shouldSendNoCounterClaimEmail() { PcsCaseEntity caseEntity = mock(PcsCaseEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -113,7 +113,7 @@ void shouldNotSendNoCounterclaimEmailIfCounterclaimExists() { CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -140,7 +140,7 @@ void shouldSendNoPaymentRequiredEmail() { CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -176,7 +176,7 @@ void shouldNotSendEmailWhenHwfRequestedAndHwfReferenceIsNull() { CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -212,7 +212,7 @@ void shouldNotSendEmailWhenHwfRequestedAndHwfReferenceIsBlank() { CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -248,7 +248,7 @@ void shouldNotSendEmailWhenHwfNotRequestedButHwfReferenceIsPresent() { CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -281,7 +281,7 @@ void shouldSendPaymentRequiredEmailWhenHwfNotRequestedAndNoHwfReference() { CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PartyEntity party = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID partyId = UUID.randomUUID(); when(defendantResponseRepository.findById(defendantResponseId)) @@ -316,7 +316,7 @@ void shouldIgnoreCounterclaimForDifferentParty() { PartyEntity defendantParty = mock(PartyEntity.class); PartyEntity otherParty = mock(PartyEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID defendantPartyId = UUID.randomUUID(); UUID otherPartyId = UUID.randomUUID(); @@ -354,7 +354,7 @@ void shouldSelectCounterclaimMatchingDefendantParty() { CounterClaimEntity otherCounterClaim = mock(CounterClaimEntity.class); CounterClaimEntity matchingCounterClaim = mock(CounterClaimEntity.class); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; UUID defendantPartyId = UUID.randomUUID(); UUID otherPartyId = UUID.randomUUID(); @@ -392,7 +392,7 @@ void shouldSelectCounterclaimMatchingDefendantParty() { void shouldSendPendingCounterClaimIssuedNotification() { UUID counterClaimId = UUID.randomUUID(); UUID partyId = UUID.randomUUID(); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; CounterClaimEntity counterClaim = mock(CounterClaimEntity.class); PcsCaseEntity pcsCase = mock(PcsCaseEntity.class); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationServiceTest.java index 92ceb2d49d..b213e204d2 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/FeePaymentNotificationServiceTest.java @@ -11,7 +11,6 @@ import uk.gov.hmcts.reform.pcs.exception.FeePaymentNotFoundException; import java.util.Optional; -import java.util.UUID; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.verify; @@ -30,7 +29,7 @@ class FeePaymentNotificationServiceTest { @Test void shouldSendClaimantClaimIssuedEmailNotification() { - UUID feePaymentId = UUID.randomUUID(); + Integer feePaymentId = 1; ClaimEntity claim = new ClaimEntity(); FeePaymentEntity feePayment = FeePaymentEntity.builder() .id(feePaymentId) @@ -45,7 +44,7 @@ void shouldSendClaimantClaimIssuedEmailNotification() { @Test void shouldThrowExceptionWhenFeePaymentNotFound() { - UUID feePaymentId = UUID.randomUUID(); + Integer feePaymentId = 1; when(feePaymentRepository.findById(feePaymentId)).thenReturn(Optional.empty()); assertThatThrownBy(() -> underTest.sendClaimantPaidCaseIssuedNotification(feePaymentId)) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationPersonalisationFactoryTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationPersonalisationFactoryTest.java index 39752a21f2..6b3f040b09 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationPersonalisationFactoryTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationPersonalisationFactoryTest.java @@ -370,7 +370,7 @@ private ClaimEntity createClaim(PartyEntity claimantParty, PartyEntity defendant private DefendantResponseEntity createDefendantResponse(PartyEntity claimantParty, PartyEntity defendantParty) { DefendantResponseEntity response = new DefendantResponseEntity(); - response.setId(UUID.randomUUID()); + response.setId(1); response.setPcsCase(pcsCaseEntity); response.setParty(defendantParty); response.setClaim(createClaim(claimantParty, defendantParty)); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationServiceTest.java index d69060268b..876d19314d 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/service/NotificationServiceTest.java @@ -102,7 +102,7 @@ class NotificationServiceTest { private static final String TEST_EMAIL = "test@example.com"; private static final String TEMPLATE_ID = "template-123"; - private static final UUID NOTIFICATION_ID = UUID.randomUUID(); + private static final Integer NOTIFICATION_ID = 1; private static final UUID PROVIDER_NOTIFICATION_ID = UUID.randomUUID(); private static final String STATUS_STRING = "delivered"; @@ -425,7 +425,7 @@ void setUp() { pcsCase.setCaseReference(CASE_REFERENCE); PaymentAgreementEntity paymentAgreement = new PaymentAgreementEntity(); - paymentAgreement.setId(UUID.randomUUID()); + paymentAgreement.setId(1); defendantResponse = new DefendantResponseEntity(); defendantResponse.setParty(party); @@ -601,7 +601,7 @@ void shouldThrowPartyNotFoundExceptionWhenClaimantIsNullInClaimantRecipient() { @DisplayName("Should throw PartyNotFoundException when defendant is null in defendantRecipient") void shouldThrowPartyNotFoundExceptionWhenDefendantIsNullInDefendantRecipient() { defendantResponse.setParty(null); - UUID responseId = UUID.randomUUID(); + Integer responseId = 1; defendantResponse.setId(responseId); assertThatThrownBy( diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/SendEmailTaskComponentTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/SendEmailTaskComponentTest.java index 36f87176e6..5cb476bce7 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/SendEmailTaskComponentTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/SendEmailTaskComponentTest.java @@ -78,7 +78,7 @@ class SendEmailTaskComponentTest { private final Duration statusCheckTaskDelay = Duration.ofMinutes(5); private SendEmailTaskData sendEmailTaskData; - private final UUID dbNotificationId = UUID.randomUUID(); + private final Integer dbNotificationId = 1; private final String templateId = "template-456"; private final String emailAddress = "test@example.com"; private final Map personalisation = Map.of("name", "John Doe"); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/VerifyEmailTaskComponentTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/VerifyEmailTaskComponentTest.java index 1b11b15f46..43dff70c01 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/VerifyEmailTaskComponentTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/notify/task/VerifyEmailTaskComponentTest.java @@ -60,7 +60,7 @@ class VerifyEmailTaskComponentTest { private final Duration statusCheckBackoffDelay = Duration.ofMinutes(2); private SendEmailTaskData sendEmailTaskData; - private final UUID dbNotificationId = UUID.randomUUID(); + private final Integer dbNotificationId = 1; private final String taskId = "verify-task-123"; private final String notificationId = "notification-456"; private final Map personalisation = Map.of("name", "John Doe"); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerTest.java index 6802ac3f17..b3c847aa2a 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/testingsupport/endpoint/NotifyControllerTest.java @@ -81,14 +81,14 @@ void shouldReturnAllEmailResponsesWhenDefendantResponseExists() { pcsCase.setCounterClaims(List.of(counterClaim)); PaymentAgreementEntity paymentAgreement = new PaymentAgreementEntity(); - paymentAgreement.setId(UUID.randomUUID()); + paymentAgreement.setId(1); DefendantResponseEntity defendantResponse = new DefendantResponseEntity(); defendantResponse.setParty(party); defendantResponse.setPcsCase(pcsCase); defendantResponse.setPaymentAgreement(paymentAgreement); - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; when(defendantResponseRepository.findById(defendantResponseId)) .thenReturn(Optional.of(defendantResponse)); @@ -127,7 +127,7 @@ void shouldReturnAllEmailResponsesWhenDefendantResponseExists() { @Test @DisplayName("Should return 404 when defendant response not found") void shouldReturn404WhenDefendantResponseNotFound() { - UUID defendantResponseId = UUID.randomUUID(); + Integer defendantResponseId = 1; when(defendantResponseRepository.findById(defendantResponseId)) .thenReturn(Optional.empty()); @@ -178,7 +178,7 @@ private EmailNotificationResponse createEmailResponse() { EmailNotificationResponse response = new EmailNotificationResponse(); response.setTaskId(TASK_ID); response.setStatus(SCHEDULED_STATUS); - response.setNotificationId(UUID.randomUUID()); + response.setNotificationId(1); return response; } }