Merge pull request #5203 from okriuchykhin/ok_SCI_6931

Update protocols migration for linked protocols [SCI-6931]
This commit is contained in:
Alex Kriuchykhin 2023-03-27 11:45:43 +02:00 committed by GitHub
commit 69445f26e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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(