Class: Domternal::Generators::MigrateFromActionTextGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/domternal/migrate_from_action_text/migrate_from_action_text_generator.rb

Overview

rails g domternal:migrate_from_action_text

Copies every action_text_rich_texts row into domternal_rich_texts, rewriting the nodes that Domternal has no equivalent for. Writes a normal timestamped migration so it runs through the usual deploy path and stays reversible.

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



21
22
23
24
# File 'lib/generators/domternal/migrate_from_action_text/migrate_from_action_text_generator.rb', line 21

def create_migration_file
  migration_template "migrate_action_text_to_domternal.rb.tt",
    "db/migrate/migrate_action_text_to_domternal.rb"
end

#show_notesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/domternal/migrate_from_action_text/migrate_from_action_text_generator.rb', line 26

def show_notes
  say <<~NOTES, :green

    Review the generated migration before running it. It:

      * copies bodies verbatim (both use sanitized HTML, so no conversion is needed)
      * turns image attachments into <img> tags on Active Storage redirect URLs, which
        is the same markup the editor's upload handler writes
      * re-attaches the referenced blobs as Domternal::RichText embeds
      * leaves action_text_rich_texts untouched, so you can roll back

    Non-image attachables (ActionText::Attachable models of your own) are dropped unless
    you tell it what to render — see ATTACHABLE_REPLACEMENTS in the migration.
  NOTES
end