Sha256: 5b61da8cef0923286976d3552c0f8b13f90f64e6588efcd42326aaa0a605874d

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module PufferPages
  module Migrations
    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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puffer_pages-0.5.1 lib/puffer_pages/migrations.rb
puffer_pages-0.5.0 lib/puffer_pages/migrations.rb