Skip to content

Commit

Permalink
Merge pull request #1326 from navikt/patch_dvh_pesys
Browse files Browse the repository at this point in the history
Patch ankeITrygderettenbehandlinger migrated from Pesys with incorrec…
  • Loading branch information
oyvind-wedoe authored Feb 3, 2025
2 parents bf0681b + 2283654 commit 74614c9
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
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()
}

}
}
}
}
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';

0 comments on commit 74614c9

Please sign in to comment.