diff --git a/db/migrate/20220818094636_fill_empty_protocol_names_for_linked_task_protocols.rb b/db/migrate/20220818094636_fill_empty_protocol_names_for_linked_task_protocols.rb new file mode 100644 index 000000000..22c62fc66 --- /dev/null +++ b/db/migrate/20220818094636_fill_empty_protocol_names_for_linked_task_protocols.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class FillEmptyProtocolNamesForLinkedTaskProtocols < ActiveRecord::Migration[6.1] + def up + execute( + "UPDATE protocols " \ + "SET name = parent_protocols.name "\ + "FROM protocols parent_protocols "\ + "WHERE \"parent_protocols\".\"id\" = \"protocols\".\"parent_id\" "\ + "AND \"protocols\".\"protocol_type\" = #{Protocol.protocol_types['linked']} "\ + "AND \"protocols\".\"name\" IS NULL;" + ) + end +end diff --git a/db/structure.sql b/db/structure.sql index ea7f62b76..68cfef0c4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -8516,6 +8516,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220429083335'), ('20220530144300'), ('20220602120714'), -('20220705091621'); +('20220705091621'), +('20220818094636');