Migrate protocol names from linked protocols in inventory if empty [SCI-7110]

This commit is contained in:
Oleksii Kriuchykhin 2022-08-18 13:25:17 +02:00
parent bf6375aee6
commit b405cadf22
2 changed files with 16 additions and 1 deletions

View file

@ -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

View file

@ -8516,6 +8516,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220429083335'),
('20220530144300'),
('20220602120714'),
('20220705091621');
('20220705091621'),
('20220818094636');