Skip to content

Commit

Permalink
Make sql schema changes in another flyway version.
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-parker committed Aug 30, 2024
1 parent db46d48 commit 4d0d5d9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions backend/src/main/resources/db/migration/V1.2__update_view.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
drop view if exists external_metadata_view cascade;

create view external_metadata_view as
select
sequence_entries_preprocessed_data.accession,
sequence_entries_preprocessed_data.version,
all_external_metadata.updated_metadata_at,
-- || concatenates two JSON objects by generating an object containing the union of their keys
-- taking the second object's value when there are duplicate keys.
case
when all_external_metadata.external_metadata is null then jsonb_build_object('metadata', (sequence_entries_preprocessed_data.processed_data->'metadata'))
else jsonb_build_object('metadata', (sequence_entries_preprocessed_data.processed_data->'metadata') || all_external_metadata.external_metadata)
end as joint_metadata
from
sequence_entries_preprocessed_data
left join all_external_metadata on
all_external_metadata.accession = sequence_entries_preprocessed_data.accession
and all_external_metadata.version = sequence_entries_preprocessed_data.version
and sequence_entries_preprocessed_data.pipeline_version = (select version from current_processing_pipeline);
2 changes: 1 addition & 1 deletion backend/src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ select
-- taking the second object's value when there are duplicate keys.
case
when all_external_metadata.external_metadata is null then jsonb_build_object('metadata', (sequence_entries_preprocessed_data.processed_data->'metadata'))
else jsonb_build_object('metadata', (sequence_entries_preprocessed_data.processed_data->'metadata') || all_external_metadata.external_metadata)
else jsonb_build_object('metadata', all_external_metadata.external_metadata || (sequence_entries_preprocessed_data.processed_data->'metadata'))
end as joint_metadata
from
sequence_entries_preprocessed_data
Expand Down

0 comments on commit 4d0d5d9

Please sign in to comment.