Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table sequencing.parcel drop constraint parcel_name_key;
call migrations.mark_migration_rolled_back(34);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- Data migration: deduplicate parcel names:
do $$
begin
-- While there are duplicate names in the parcel table...
while exists(
select from sequencing.parcel
group by name
having count(name) > 1
) loop
-- ...deduplicate them
update sequencing.parcel
set name = name || '(' || ir.row || ')'
from (
select id, row_number() over (partition by name) - 1 as row
from sequencing.parcel
where name in (
select p.name
from sequencing.parcel p
group by p.name
having count(1) > 1)
) as ir
where ir.id = parcel.id
and row > 0;
end loop;
end $$;

-- Add new uniqueness constraint to the parcel name
alter table sequencing.parcel
add unique(name);

call migrations.mark_migration_applied(34);
1 change: 1 addition & 0 deletions deployment/postgres-init-db/sql/applied_migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ call migrations.mark_migration_applied(30);
call migrations.mark_migration_applied(31);
call migrations.mark_migration_applied(32);
call migrations.mark_migration_applied(33);
call migrations.mark_migration_applied(34);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
create table sequencing.parcel (
id integer generated always as identity,

name text not null,
name text not null unique,

command_dictionary_id integer not null,
channel_dictionary_id integer default null,
Expand Down
Loading