Skip to content

Commit

Permalink
Simplify logic for minting new ids for items and values #23
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Aug 15, 2024
1 parent 1cd0ae4 commit d9486d7
Showing 1 changed file with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class Migration(migrations.Migration):
declare failed_collections text[];
collection text;
rec record;
new_listitem_id uuid;
new_listitemvalue_id uuid;
begin
-- RDM Collections to Controlled Lists & List Items Migration --
-- To use, run:
Expand Down Expand Up @@ -253,6 +251,7 @@ class Migration(migrations.Migration):
end loop;
-- Assign row number to help identify concepts that participate in multiple collections
-- or exist already as listitems and therefore need new listitem_id's and listitemvalue_id's
with assign_row_num as (
select list_item_id,
sortorder,
Expand Down Expand Up @@ -283,23 +282,11 @@ class Migration(migrations.Migration):
and t.list_id = a.list_id;
-- For concepts that participate in multiple collections, mint new listitem_id's and listitemvalue_id's
for rec in
select *
from temp_list_items_and_values
where rownumber > 1
and listitemvalue_valuetype = 'prefLabel'
loop
if rec.rownumber > 1
then
new_listitem_id := uuid_generate_v4();
new_listitemvalue_id := uuid_generate_v4();
update temp_list_items_and_values
set list_item_id = new_listitem_id,
listitemvalue_id = new_listitemvalue_id
where list_item_id = rec.list_item_id
and rownumber = rec.rownumber;
end if;
end loop;
update temp_list_items_and_values
set list_item_id = uuid_generate_v4(),
listitemvalue_id = uuid_generate_v4()
where rownumber > 1
and listitemvalue_valuetype = 'prefLabel';
insert into arches_references_listitem (
id,
Expand Down

0 comments on commit d9486d7

Please sign in to comment.