Skip to content

Commit

Permalink
Adjust upgrader to page legacy timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Feb 12, 2021
1 parent f570c7b commit bb8287c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/alchemy/upgrader/tasks/add_page_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ class AddPageVersions < Thor

no_tasks do
def create_public_page_versions
Alchemy::Page.where.not(public_on: nil).find_each do |page|
next if page.versions.published.any?
Alchemy::Deprecation.silence do
Alchemy::Page.where.not(legacy_public_on: nil).find_each do |page|
next if page.versions.published.any?

Alchemy::Page.transaction do
page.versions.create!(
public_on: page.public_on,
public_until: page.public_until
).tap do |version|
# We must not use .find_each here to not mess up the order of elements
page.draft_version.elements.not_nested.available.each do |element|
Alchemy::Element.copy(element, page_version_id: version.id)
Alchemy::Page.transaction do
page.versions.create!(
public_on: page.legacy_public_on,
public_until: page.legacy_public_until
).tap do |version|
# We must not use .find_each here to not mess up the order of elements
page.draft_version.elements.not_nested.available.each do |element|
Alchemy::Element.copy(element, page_version_id: version.id)
end
end
end
end

print "."
print "."
end
end
end
end
Expand Down

0 comments on commit bb8287c

Please sign in to comment.