Sha256: f43dcf0848abb297de2b512fdaf38521bcf59ad388ecd052ab0b3ad28a1aa7fb
Contents?: true
Size: 797 Bytes
Versions: 3
Compression:
Stored size: 797 Bytes
Contents
class ConvertPostContentToEditorJs < ActiveRecord::Migration[7.1] def up Panda::CMS::Post.find_each do |post| next if post.post_content.blank? editor_content = { time: Time.current.to_i, version: "2.28.2", blocks: [ { type: "paragraph", data: { text: post.post_content.to_plain_text } } ] } post.update_column(:content, editor_content) end end def down Panda::CMS::Post.find_each do |post| next if post.content.blank? # Extract plain text from EditorJS format plain_text = post.content["blocks"] &.map { |block| block["data"]["text"] } &.join("\n") post.update_column(:content, plain_text) end end end
Version data entries
3 entries across 3 versions & 1 rubygems