Update protocols migration for linked protocols [SCI-6931]

This commit is contained in:
Oleksii Kriuchykhin 2023-03-27 11:39:09 +02:00
parent 09a217baca
commit 9885dc0f29
2 changed files with 7 additions and 4 deletions

View file

@ -351,7 +351,11 @@ class Protocol < ApplicationRecord
end
def parent_newer?
linked? && parent.newer_published_version_present?
linked? && (
parent.newer_published_version_present? ||
# backward compatibility with original implementation
parent.published_on > updated_at
)
end
def number_of_steps

View file

@ -36,9 +36,8 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
');'
)
execute(
'UPDATE "protocols" SET "published_on" = "created_at", "published_by_id" = "added_by_id" ' \
'WHERE "protocols"."protocol_type" = 5 ' \
'AND "protocols"."published_on" IS NULL;'
'UPDATE "protocols" SET "published_on" = "updated_at", "published_by_id" = "added_by_id" ' \
'WHERE "protocols"."protocol_type" = 5;'
)
execute(