Class: Killbill::Migration
Class Attribute Summary collapse
-
.ar_patched ⇒ Object
Returns the value of attribute ar_patched.
Instance Method Summary collapse
- #current_version ⇒ Object
-
#initialize(plugin_name, config = nil, logger = Logger.new(STDOUT)) ⇒ Migration
constructor
A new instance of Migration.
- #migrate(migrations_paths = ActiveRecord::Migrator.migrations_paths) ⇒ Object
- #ruby_dump(stream = StringIO.new) ⇒ Object
- #sql_dump(stream = StringIO.new) ⇒ Object
- #sql_for_migration(migrations_paths = ActiveRecord::Migrator.migrations_paths) ⇒ Object
Constructor Details
#initialize(plugin_name, config = nil, logger = Logger.new(STDOUT)) ⇒ Migration
Returns a new instance of Migration.
27 28 29 30 31 32 33 |
# File 'lib/killbill/migration.rb', line 27 def initialize(plugin_name, config = nil, logger = Logger.new(STDOUT)) configure_logging(logger) configure_migration(plugin_name) configure_connection(config) monkey_patch_ar end |
Class Attribute Details
.ar_patched ⇒ Object
Returns the value of attribute ar_patched.
24 25 26 |
# File 'lib/killbill/migration.rb', line 24 def ar_patched @ar_patched end |
Instance Method Details
#current_version ⇒ Object
49 50 51 |
# File 'lib/killbill/migration.rb', line 49 def current_version ActiveRecord::Migrator.current_version end |
#migrate(migrations_paths = ActiveRecord::Migrator.migrations_paths) ⇒ Object
43 44 45 46 47 |
# File 'lib/killbill/migration.rb', line 43 def migrate(migrations_paths = ActiveRecord::Migrator.migrations_paths) ActiveRecord::Base.connection.readonly = false ActiveRecord::Migrator.migrate(migrations_paths) end |
#ruby_dump(stream = StringIO.new) ⇒ Object
62 63 64 |
# File 'lib/killbill/migration.rb', line 62 def ruby_dump(stream = StringIO.new) ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) end |
#sql_dump(stream = StringIO.new) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/killbill/migration.rb', line 53 def sql_dump(stream = StringIO.new) Dir.mktmpdir do |dir| filename = File.join(dir, 'structure.sql') ActiveRecord::Tasks::DatabaseTasks.structure_dump(@config, filename) stream.write(File.read(filename)) end stream end |
#sql_for_migration(migrations_paths = ActiveRecord::Migrator.migrations_paths) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/killbill/migration.rb', line 35 def sql_for_migration(migrations_paths = ActiveRecord::Migrator.migrations_paths) ActiveRecord::Base.connection.readonly = true ActiveRecord::Migrator.migrate(migrations_paths) ActiveRecord::Base.connection.migration_statements end |