From 91719e433309aa417ba0a3e7f603a674d0cf1841 Mon Sep 17 00:00:00 2001 From: markodraksic Date: Wed, 8 Nov 2023 11:07:17 +0100 Subject: [PATCH] Edit sivilstandtype enum --- .../database/datamodell/SivilstandType.kt | 10 +--------- .../V1.0.30__edit_sivilstandType_enum.sql | 17 +++++++++++++++++ .../behandling/service/BehandlingServiceTest.kt | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/db/migration/V1.0.30__edit_sivilstandType_enum.sql diff --git a/src/main/kotlin/no/nav/bidrag/behandling/database/datamodell/SivilstandType.kt b/src/main/kotlin/no/nav/bidrag/behandling/database/datamodell/SivilstandType.kt index 1d9434caa..419fbbff8 100644 --- a/src/main/kotlin/no/nav/bidrag/behandling/database/datamodell/SivilstandType.kt +++ b/src/main/kotlin/no/nav/bidrag/behandling/database/datamodell/SivilstandType.kt @@ -5,14 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema // TODO Bruk Sivilstandstype fra bidrag-domain istedenfor @Schema(enumAsRef = true) enum class SivilstandType { - ENKE_ELLER_ENKEMANN, + BOR_ALENE_MED_BARN, GIFT, - GJENLEVENDE_PARTNER, - REGISTRERT_PARTNER, - SEPARERT, - SEPARERT_PARTNER, - SKILT, - SKILT_PARTNER, - UGIFT, - UOPPGITT, } diff --git a/src/main/resources/db/migration/V1.0.30__edit_sivilstandType_enum.sql b/src/main/resources/db/migration/V1.0.30__edit_sivilstandType_enum.sql new file mode 100644 index 000000000..3427b61ae --- /dev/null +++ b/src/main/resources/db/migration/V1.0.30__edit_sivilstandType_enum.sql @@ -0,0 +1,17 @@ +alter type SIVILSTAND_TYPE rename to SIVILSTAND_TYPE_OLD; + +CREATE TYPE SIVILSTAND_TYPE AS ENUM + ( + 'BOR_ALENE_MED_BARN', + 'GIFT' + ); + +CREATE CAST (VARCHAR AS SIVILSTAND_TYPE) WITH INOUT AS IMPLICIT; +alter table SIVILSTAND rename column SIVILSTAND_TYPE to SIVILSTAND_TYPE_OLD; + +ALTER TABLE SIVILSTAND + ADD COLUMN SIVILSTAND_TYPE SIVILSTAND_TYPE DEFAULT 'BOR_ALENE_MED_BARN' not null ; +update SIVILSTAND set SIVILSTAND_TYPE = 'BOR_ALENE_MED_BARN' where SIVILSTAND_TYPE_OLD != 'GIFT'; + +ALTER TABLE SIVILSTAND DROP COLUMN IF EXISTS SIVILSTAND_TYPE_OLD cascade; +drop type SIVILSTAND_TYPE_OLD cascade; \ No newline at end of file diff --git a/src/test/kotlin/no/nav/bidrag/behandling/service/BehandlingServiceTest.kt b/src/test/kotlin/no/nav/bidrag/behandling/service/BehandlingServiceTest.kt index b4fbce3fc..b827300a3 100644 --- a/src/test/kotlin/no/nav/bidrag/behandling/service/BehandlingServiceTest.kt +++ b/src/test/kotlin/no/nav/bidrag/behandling/service/BehandlingServiceTest.kt @@ -125,7 +125,7 @@ class BehandlingServiceTest : TestContainerRunner() { null, Calendar.getInstance().time.toLocalDate(), Calendar.getInstance().time.toLocalDate(), - SivilstandType.ENKE_ELLER_ENKEMANN, + SivilstandType.BOR_ALENE_MED_BARN, ), )