Class: Cardio::Migration
- Inherits:
-
Object
show all
- Extended by:
- Port
- Includes:
- Assumption, Stamp
- Defined in:
- lib/cardio/migration.rb,
lib/cardio/migration/port.rb,
lib/cardio/migration/stamp.rb,
lib/cardio/migration/schema.rb,
lib/cardio/migration/transform.rb,
lib/cardio/migration/assumption.rb
Defined Under Namespace
Modules: Assumption, Port, Stamp
Classes: Schema, Transform
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Port
port, port_all
Methods included from Stamp
#stamp
Methods included from Assumption
#assume_current, #assume_migrated_upto_version
Class Attribute Details
.migration_type ⇒ Object
Returns the value of attribute migration_type.
10
11
12
|
# File 'lib/cardio/migration.rb', line 10
def migration_type
@migration_type
end
|
.old_deck_table ⇒ Object
Returns the value of attribute old_deck_table.
10
11
12
|
# File 'lib/cardio/migration.rb', line 10
def old_deck_table
@old_deck_table
end
|
.old_tables ⇒ Object
Returns the value of attribute old_tables.
10
11
12
|
# File 'lib/cardio/migration.rb', line 10
def old_tables
@old_tables
end
|
Class Method Details
.migration_class(type) ⇒ Object
.new_for(type) ⇒ Object
16
17
18
|
# File 'lib/cardio/migration.rb', line 16
def new_for type
migration_class(type).new
end
|
Instance Method Details
#context ⇒ Object
47
48
49
50
51
52
|
# File 'lib/cardio/migration.rb', line 47
def context
mode do |paths|
migrations = ActiveRecord::SchemaMigration.new ActiveRecord::Base.connection_pool
yield ActiveRecord::MigrationContext.new(paths, migrations)
end
end
|
#down ⇒ Object
58
59
60
|
# File 'lib/cardio/migration.rb', line 58
def down
raise ActiveRecord::IrreversibleMigration
end
|
#migration_paths ⇒ Object
43
44
45
|
# File 'lib/cardio/migration.rb', line 43
def migration_paths
Cardio.paths["data/#{migration_type}"].existent.to_a
end
|
#migration_type ⇒ Object
27
28
29
|
# File 'lib/cardio/migration.rb', line 27
def migration_type
self.class.migration_type || :schema
end
|
#mode ⇒ Object
54
55
56
|
# File 'lib/cardio/migration.rb', line 54
def mode
with_migration_table { yield migration_paths }
end
|
#run(version = nil, verbose = true) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/cardio/migration.rb', line 31
def run version=nil, verbose=true
context do |mc|
ActiveRecord::Migration.verbose = verbose
mc.migrate version
end
end
|
#version ⇒ Object
38
39
40
41
|
# File 'lib/cardio/migration.rb', line 38
def version
path = stamp_path
File.exist?(path) ? File.read(path).strip : nil
end
|