Skip to content

Commit

Permalink
json->jsonb to allow indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-meidell committed Oct 3, 2023
1 parent 2182925 commit 88c4dce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BarnetrygdmottakerRepository(
keyHolder
)
jdbcTemplate.update(
"""insert into barnetrygdmottaker_status (id, status, statushistorikk) values (:id, to_json(:status::json), to_json(:statushistorikk::json))""",
"""insert into barnetrygdmottaker_status (id, status, statushistorikk) values (:id, to_jsonb(:status::jsonb), to_jsonb(:statushistorikk::jsonb))""",
MapSqlParameterSource(
mapOf<String, Any>(
"id" to keyHolder.keys!!["id"] as UUID,
Expand All @@ -49,7 +49,7 @@ class BarnetrygdmottakerRepository(

fun updateStatus(barnetrygdmottaker: Barnetrygdmottaker.Mottatt) {
jdbcTemplate.update(
"""update barnetrygdmottaker_status set status = to_json(:status::json), statushistorikk = to_json(:statushistorikk::json) where id = :id""",
"""update barnetrygdmottaker_status set status = to_jsonb(:status::jsonb), statushistorikk = to_jsonb(:statushistorikk::jsonb) where id = :id""",
MapSqlParameterSource(
mapOf<String, Any>(
"id" to barnetrygdmottaker.id,
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/db/migration/V3__json_to_jsonb.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table barnetrygdmottaker_status alter column status set data type jsonb using status::jsonb;
alter table barnetrygdmottaker_status alter column statushistorikk set data type jsonb using statushistorikk::jsonb;

0 comments on commit 88c4dce

Please sign in to comment.