Module: PufferPages::Migrations

Defined in:
lib/puffer_pages/migrations.rb

Class Method Summary collapse

Class Method Details

.create_translation_tables!(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/puffer_pages/migrations.rb', line 3

def self.create_translation_tables! options = {}
  unless PufferPages.localize
    puts "WARN: Translation tables creation skip. Set `PufferPages.localize = true` to perform it"
    return
  end
  options = options.reverse_merge migrate_data: true

  [PufferPages::PagePart, PufferPages::Layout, PufferPages::Snippet].each do |model|
    model.create_translation_table!({
      body: { type: :text }
    }, options)
    puts "-- Created translation table for #{model} with #{options}"
  end
end

.drop_translation_tables!(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puffer_pages/migrations.rb', line 18

def self.drop_translation_tables! options = {}
  unless PufferPages.localize
    puts "WARN: Translation tables dropping skip. Set `PufferPages.localize = true` to perform it"
    return
  end
  options = options.reverse_merge migrate_data: true

  [PufferPages::PagePart, PufferPages::Layout, PufferPages::Snippet].each do |model|
    model.drop_translation_table! options
    puts "-- Dropped translation table for #{model} with #{options}"
  end
end