diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementMigration.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementMigration.java index ce6d4b8c4..df7a5a1ce 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementMigration.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementMigration.java @@ -20,6 +20,7 @@ public class ArenaAgreementMigration { @Id private UUID id; private Integer tiltakgjennomforingId; + private Integer tiltakdeltakerId; @Enumerated(EnumType.STRING) private ArenaAgreementMigrationStatus status; @Enumerated(EnumType.STRING) diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/repository/ArenaAgreementMigrationRepository.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/repository/ArenaAgreementMigrationRepository.java index 1568d5768..2c15bd0cd 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/repository/ArenaAgreementMigrationRepository.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/repository/ArenaAgreementMigrationRepository.java @@ -34,10 +34,11 @@ public interface ArenaAgreementMigrationRepository extends JpaRepository findMigrationAgreementAggregates(); diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java index b2cb4b104..287fb24df 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java @@ -79,6 +79,7 @@ public ArenaAgreementProcessingService( public void process(ArenaAgreementAggregate agreementAggregate) { UUID eksternId = agreementAggregate.getEksternIdAsUuid().orElse(null); Integer tiltaksgjennomforingId = agreementAggregate.getTiltakgjennomforingId(); + Integer tiltakdeltakerId = agreementAggregate.getTiltakdeltakerId(); try { ArenaMigrationProcessResult result = agreementAggregate.getEksternIdAsUuid() @@ -99,6 +100,7 @@ public void process(ArenaAgreementAggregate agreementAggregate) { ); saveMigrationStatus( tiltaksgjennomforingId, + tiltakdeltakerId, ArenaAgreementMigrationStatus.COMPLETED, completed.action(), eksternId, @@ -108,6 +110,7 @@ public void process(ArenaAgreementAggregate agreementAggregate) { case ArenaMigrationProcessResult.Ignored ignored -> saveMigrationStatus( tiltaksgjennomforingId, + tiltakdeltakerId, ArenaAgreementMigrationStatus.COMPLETED, ignored.action(), eksternId, @@ -121,6 +124,7 @@ public void process(ArenaAgreementAggregate agreementAggregate) { log.error("Feil ved prossesering av avtale fra Arena", e); saveMigrationStatus( tiltaksgjennomforingId, + tiltakdeltakerId, ArenaAgreementMigrationStatus.FAILED, null, eksternId, @@ -131,6 +135,7 @@ public void process(ArenaAgreementAggregate agreementAggregate) { private void saveMigrationStatus( Integer tiltakgjennomforingId, + Integer tiltakdeltakerId, ArenaAgreementMigrationStatus status, ArenaMigrationAction action, UUID eksternId, @@ -140,6 +145,7 @@ private void saveMigrationStatus( ArenaAgreementMigration.builder() .id(UUID.randomUUID()) .tiltakgjennomforingId(tiltakgjennomforingId) + .tiltakdeltakerId(tiltakdeltakerId) .status(status) .action(action) .avtaleId(agreementId) diff --git a/src/main/resources/db/migration/V117__tiltakdeltaker_id_arena-agreement_migration.sql b/src/main/resources/db/migration/V117__tiltakdeltaker_id_arena-agreement_migration.sql new file mode 100644 index 000000000..2e8d48576 --- /dev/null +++ b/src/main/resources/db/migration/V117__tiltakdeltaker_id_arena-agreement_migration.sql @@ -0,0 +1,14 @@ +ALTER TABLE arena_agreement_migration ADD COLUMN tiltakdeltaker_id int; + +UPDATE arena_agreement_migration aam +SET tiltakdeltaker_id = ( + SELECT tiltakdeltaker_id + FROM arena_tiltakdeltaker + WHERE tiltakgjennomforing_id = aam.tiltakgjennomforing_id + LIMIT 1 +); + +ALTER TABLE arena_agreement_migration +ADD CONSTRAINT arena_agreement_migration_tiltakdeltaker_id_fkey +FOREIGN KEY (tiltakdeltaker_id) +REFERENCES arena_tiltakdeltaker(tiltakdeltaker_id);