Skip to content

Commit

Permalink
♻️ Knytt oppgave til generasjon_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
chsko committed Mar 19, 2024
1 parent f65e961 commit eb1c52b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE oppgave ADD COLUMN generasjon_ref UUID;

UPDATE oppgave o SET generasjon_ref = (
SELECT unik_id FROM selve_vedtaksperiode_generasjon svg WHERE vedtaksperiode_id = (
SELECT vedtaksperiode_id FROM vedtak v WHERE v.id = o.vedtak_ref
) ORDER BY id DESC LIMIT 1
) WHERE status = 'AvventerSaksbehandler';
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,24 @@ class OppgaveDao(dataSource: DataSource) : HelseDao(dataSource), OppgaveReposito

asSQL(
"""
INSERT INTO oppgave(id, oppdatert, status, ferdigstilt_av, ferdigstilt_av_oid, vedtak_ref, command_context_id, utbetaling_id, mottaker, egenskaper, kan_avvises)
SELECT :id, now(), CAST(:oppgavestatus as oppgavestatus), :ferdigstiltAv, :ferdigstiltAvOid, :vedtakRef, :commandContextId, :utbetalingId, CAST(:mottaker as mottakertype), '{$egenskaperForDatabase}', :kanAvvises
INSERT INTO oppgave(id, oppdatert, status, ferdigstilt_av, ferdigstilt_av_oid, vedtak_ref, generasjon_ref, command_context_id, utbetaling_id, mottaker, egenskaper, kan_avvises)
SELECT
:id,
now(),
CAST(:oppgavestatus as oppgavestatus),
:ferdigstiltAv,
:ferdigstiltAvOid,
:vedtakRef,
(
SELECT unik_id FROM selve_vedtaksperiode_generasjon svg WHERE vedtaksperiode_id = (
SELECT vedtaksperiode_id FROM vedtak v WHERE v.id = :vedtakRef
) ORDER BY id DESC LIMIT 1
),
:commandContextId,
:utbetalingId,
CAST(:mottaker as mottakertype),
'{$egenskaperForDatabase}',
:kanAvvises
WHERE
NOT EXISTS(
SELECT 1 FROM oppgave o
Expand Down

0 comments on commit eb1c52b

Please sign in to comment.