Sha256: 8d37a1d08a7e0cd7c954838815e34173cd4a96e1c4f12768ac67956c6093b795

Contents?: true

Size: 719 Bytes

Versions: 6

Compression:

Stored size: 719 Bytes

Contents

# -*- encoding : utf-8 -*-

module Wagn::MigrationHelper
  def self.card_migration_paths
    Wagn.paths['db/migrate_cards'].to_a
  end
  
  def self.schema_mode type
    new_suffix = type.to_s =~ /card/ ? '_cards' : ''
    original_suffix = ActiveRecord::Base.table_name_suffix
    ActiveRecord::Base.table_name_suffix = new_suffix
    yield
    ActiveRecord::Base.table_name_suffix = original_suffix
  end
  
  def contentedly &block
    Wagn::Cache.reset_global
    Wagn::MigrationHelper.schema_mode '' do
      Account.as_bot do
        ActiveRecord::Base.transaction do
          begin
            yield
          ensure
            Wagn::Cache.reset_global
          end
        end
      end
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wagn-1.12.13 lib/wagn/migration_helper.rb
wagn-1.12.12 lib/wagn/migration_helper.rb
wagn-1.12.11 lib/wagn/migration_helper.rb
wagn-1.12.10 lib/wagn/migration_helper.rb
wagn-1.12.9 lib/wagn/migration_helper.rb
wagn-1.12.8 lib/wagn/migration_helper.rb