-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1326 from navikt/patch_dvh_pesys
Patch ankeITrygderettenbehandlinger migrated from Pesys with incorrec…
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/kotlin/db/migration/V183__dvh_pesys_fix_migrated_anker_i_tr.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package db.migration | ||
|
||
import no.nav.klage.oppgave.domain.kafka.StatistikkTilDVH | ||
import no.nav.klage.oppgave.util.ourJacksonObjectMapper | ||
import org.flywaydb.core.api.migration.BaseJavaMigration | ||
import org.flywaydb.core.api.migration.Context | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
class V183__dvh_pesys_fix_migrated_anker_i_tr : BaseJavaMigration() { | ||
override fun migrate(context: Context) { | ||
val preparedStatement = context.connection.prepareStatement( | ||
""" | ||
update klage.kafka_event | ||
set json_payload = ?, status_id = ? | ||
where id = ? | ||
""".trimIndent() | ||
) | ||
|
||
context.connection.createStatement().use { select -> | ||
select.executeQuery( | ||
""" | ||
select ke.id, ke.json_payload | ||
from klage.kafka_event ke | ||
where ke.type = 'STATS_DVH' | ||
and ke.kilde_referanse in ( | ||
'65078640', | ||
'65693125', | ||
'66219670') | ||
""" | ||
) | ||
.use { rows -> | ||
while (rows.next()) { | ||
val kafkaEventId = rows.getObject(1, UUID::class.java) | ||
val jsonPayload = rows.getString(2) | ||
|
||
val statistikkTilDVH = | ||
ourJacksonObjectMapper().readValue(jsonPayload, StatistikkTilDVH::class.java) | ||
|
||
val modifiedVersion = when (statistikkTilDVH.behandlingId) { | ||
"46577693" -> statistikkTilDVH.copy(behandlingId = "48428906", tekniskTid = LocalDateTime.now()) | ||
"47286111" -> statistikkTilDVH.copy(behandlingId = "49052740", tekniskTid = LocalDateTime.now()) | ||
"48339550" -> statistikkTilDVH.copy(behandlingId = "49188049", tekniskTid = LocalDateTime.now()) | ||
else -> throw RuntimeException("Unknown behandlingId: ${statistikkTilDVH.behandlingId}") | ||
} | ||
|
||
preparedStatement.setString(1, ourJacksonObjectMapper().writeValueAsString(modifiedVersion)) | ||
preparedStatement.setObject(2,"IKKE_SENDT") | ||
preparedStatement.setObject(3, kafkaEventId) | ||
|
||
preparedStatement.executeUpdate() | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/resources/db/migration/V182__pesys_fix_dvh_ref_anker_i_tr.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--mottak | ||
UPDATE klage.mottak | ||
SET dvh_referanse = '48428906' | ||
WHERE kilde_referanse = '65078640' | ||
AND dvh_referanse = '46577693'; | ||
UPDATE klage.mottak | ||
SET dvh_referanse = '49052740' | ||
WHERE kilde_referanse = '65693125' | ||
AND dvh_referanse = '47286111'; | ||
UPDATE klage.mottak | ||
SET dvh_referanse = '49188049' | ||
WHERE kilde_referanse = '66219670' | ||
AND dvh_referanse = '48339550'; | ||
|
||
-- behandling | ||
UPDATE klage.behandling | ||
SET dvh_referanse = '48428906' | ||
WHERE kilde_referanse = '65078640' | ||
AND dvh_referanse = '46577693'; | ||
UPDATE klage.behandling | ||
SET dvh_referanse = '49052740' | ||
WHERE kilde_referanse = '65693125' | ||
AND dvh_referanse = '47286111'; | ||
UPDATE klage.behandling | ||
SET dvh_referanse = '49188049' | ||
WHERE kilde_referanse = '66219670' | ||
AND dvh_referanse = '48339550'; |