class Cardio::Migration

Attributes

migration_type[R]
old_deck_table[R]
old_tables[R]

Public Class Methods

migration_class(type) click to toggle source
# File lib/cardio/migration.rb, line 11
def migration_class type
  type == :schema ? Migration::Schema : Migration::Transform
end
new_for(type) click to toggle source
# File lib/cardio/migration.rb, line 15
def new_for type
  migration_class(type).new
end

Private Class Methods

table() click to toggle source
# File lib/cardio/migration.rb, line 21
def table
  "#{migration_type}_migrations"
end

Public Instance Methods

context() { |migration_context| ... } click to toggle source
# File lib/cardio/migration.rb, line 46
def context
  mode do |paths|
    migrations = ActiveRecord::SchemaMigration.new ActiveRecord::Base.connection_pool
    yield ActiveRecord::MigrationContext.new(paths, migrations)
  end
end
down() click to toggle source
# File lib/cardio/migration.rb, line 57
def down
  raise ActiveRecord::IrreversibleMigration
end
migration_paths() click to toggle source
# File lib/cardio/migration.rb, line 42
def migration_paths
  Cardio.paths["data/#{migration_type}"].existent.to_a
end
migration_type() click to toggle source
# File lib/cardio/migration.rb, line 26
def migration_type
  self.class.migration_type || :schema
end
mode() { |migration_paths| ... } click to toggle source
# File lib/cardio/migration.rb, line 53
def mode
  with_migration_table { yield migration_paths }
end
run(version=nil, verbose=true) click to toggle source
# File lib/cardio/migration.rb, line 30
def run version=nil, verbose=true
  context do |mc|
    ActiveRecord::Migration.verbose = verbose
    mc.migrate version
  end
end
version() click to toggle source
# File lib/cardio/migration.rb, line 37
def version
  path = stamp_path
  File.exist?(path) ? File.read(path).strip : nil
end

Private Instance Methods

table_name=(table_name) click to toggle source
# File lib/cardio/migration.rb, line 67
def table_name= table_name
  ActiveRecord::Base.schema_migrations_table_name = table_name
  # ActiveRecord::SchemaMigration.table_name = table_name
  # ActiveRecord::SchemaMigration.reset_column_information
end
with_migration_table() { || ... } click to toggle source
# File lib/cardio/migration.rb, line 63
def with_migration_table
  yield
end