Class: ActiveRecord::Migration
- Inherits:
-
Object
- Object
- ActiveRecord::Migration
- Defined in:
- lib/migration.rb
Class Method Summary collapse
- .method_missing(method, *arguments, &block) ⇒ Object
- .migrate(direction) ⇒ Object
- .name ⇒ Object
- .source_migrate ⇒ Object
- .with_database_of(model) ⇒ Object
Class Method Details
.method_missing(method, *arguments, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/migration.rb', line 36 def method_missing(method, *arguments, &block) arg_list = arguments.map(&:inspect) * ', ' msg = "#{method}(#{arg_list})" msg += " db: #{@conn.current_database}" if @conn && @conn.respond_to?(:current_database) say_with_time msg do unless arguments.empty? || method == :execute arguments[0] = ActiveRecord::Migrator.proper_table_name(arguments.first) end (@conn || ActiveRecord::Base.connection).send(method, *arguments, &block) end end |
.migrate(direction) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/migration.rb', line 29 def migrate(direction) if ActiveRecord::Base.run_on_slave_db ActiveRecord::Base.configurations[RAILS_ENV] = ActiveRecord::Base.configurations[RAILS_ENV + "_slave"] end source_migrate(direction) unless (ActiveRecord::Base.run_on_slave_db and @skip_on_slave) end |
.name ⇒ Object
50 51 52 |
# File 'lib/migration.rb', line 50 def self.name "WithDatabaseOf" end |
.source_migrate ⇒ Object
28 |
# File 'lib/migration.rb', line 28 alias_method :source_migrate, :migrate |
.with_database_of(model) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/migration.rb', line 18 def with_database_of model @conn = model.connection raise "NULL connection!" if @conn.nil? returning yield do @conn = nil end end |