class Cardio::Migration
Base class for both schema and transform card migrations, which are found in <mod>/data/schema and <mod>/data/transform respectively
Attributes
Public Class Methods
Source
# File lib/cardio/migration.rb, line 13 def migration_class type type == :schema ? Migration::Schema : Migration::Transform end
Source
# File lib/cardio/migration.rb, line 17 def new_for type migration_class(type).new end
Private Class Methods
Source
# File lib/cardio/migration.rb, line 23 def table "#{migration_type}_migrations" end
Public Instance Methods
Source
# File lib/cardio/migration.rb, line 48 def context mode do |paths| migrations = ActiveRecord::SchemaMigration.new ActiveRecord::Base.connection_pool yield ActiveRecord::MigrationContext.new(paths, migrations) end end
Source
# File lib/cardio/migration.rb, line 59 def down raise ActiveRecord::IrreversibleMigration end
Source
# File lib/cardio/migration.rb, line 44 def migration_paths Cardio.paths["data/#{migration_type}"].existent.to_a end
Source
# File lib/cardio/migration.rb, line 28 def migration_type self.class.migration_type || :schema end
Source
# File lib/cardio/migration.rb, line 55 def mode with_migration_table { yield migration_paths } end
Source
# File lib/cardio/migration.rb, line 32 def run version=nil, verbose=true context do |mc| ActiveRecord::Migration.verbose = verbose mc.migrate version end end
Source
# File lib/cardio/migration.rb, line 39 def version path = stamp_path File.exist?(path) ? File.read(path).strip : nil end
Private Instance Methods
Source
# File lib/cardio/migration.rb, line 69 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
Source
# File lib/cardio/migration.rb, line 65 def with_migration_table yield end