-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
11 deletions.
There are no files selected for viewing
67 changes: 56 additions & 11 deletions
67
apps/backend/src/main/resources/db/migration/V1.24__etterlevelse_egen_tabell.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 |
---|---|---|
@@ -1,15 +1,60 @@ | ||
CREATE TABLE IF NOT EXISTS ETTERLEVELSE | ||
-- Denne migrasjonen trekker etterlevelse ut til egen tabell | ||
|
||
-- Lag ny tabell... | ||
|
||
create table etterlevelse | ||
( | ||
ID UUID PRIMARY KEY, | ||
|
||
DATA JSONB NOT NULL, | ||
CREATED_BY TEXT NOT NULL, | ||
CREATED_DATE TIMESTAMP NOT NULL, | ||
LAST_MODIFIED_BY TEXT NOT NULL, | ||
LAST_MODIFIED_DATE TIMESTAMP NOT NULL, | ||
VERSION INTEGER NOT NULL | ||
id uuid primary key, | ||
behandling_id text not null, | ||
dokumentasjon_id text not null, | ||
krav_nummer integer not null, | ||
krav_versjon integer not null, | ||
data jsonb not null, | ||
created_by text not null, | ||
created_date timestamp not null, | ||
last_modified_by text not null, | ||
last_modified_date timestamp not null, | ||
version integer not null | ||
); | ||
|
||
-- FIXME: Legg til indekser | ||
-- Opprett indekser for felt som søkes på... | ||
|
||
create index idx_etterlevelse_dokumentasjon_id on etterlevelse(dokumentasjon_id); | ||
create index idx_etterlevelse_krav_nummer on etterlevelse(krav_nummer); | ||
|
||
-- Populer tabellen... | ||
|
||
insert into etterlevelse | ||
select | ||
id, | ||
data -> behandlingId, | ||
data -> dokumentasjonId, | ||
data -> kravNummer, | ||
data -> kravVersjon, | ||
data - 'behandlingId' - 'dokumentasjonId' - 'kravNummer' - 'kravVersjon', | ||
created_by, | ||
created_date, | ||
last_modified_by, | ||
last_modified_date, | ||
version | ||
from generic_storage | ||
where type = 'Etterlevelse' | ||
; | ||
|
||
-- Drop den gamle indeksen på etterlevelseDokumentasjonId (opprettet i 1.23)... | ||
-- FIXME | ||
|
||
-- Slett rader i den gamle tabellen... | ||
|
||
delete from generic_storage where type = 'Etterlevelse'; | ||
|
||
-- Rydd opp i generic_storage... | ||
|
||
vacuum full generic_storage; | ||
|
||
-- Oppdater audit_version... | ||
|
||
-- FIXME | ||
|
||
|
||
|
||
-- FIXME: Legg til migrering |