Sha256: 8f22c23622ab9513dd60a15fb391db036201bb2c3cc2b2cc5eabd1bc1b6b9420

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 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
      Card::Auth.as_bot do
        ActiveRecord::Base.transaction do
          begin
            yield
          ensure
            Wagn::Cache.reset_global
          end
        end
      end
    end
  end
  
  def down
    raise ActiveRecord::IrreversibleMigration
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wagn-1.13.0 lib/wagn/migration_helper.rb
wagn-1.13.0.pre2 lib/wagn/migration_helper.rb
wagn-1.13.0.pre1 lib/wagn/migration_helper.rb
wagn-1.13.0.pre lib/wagn/migration_helper.rb