Class: Landable::Migration
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- Landable::Migration
- Defined in:
- lib/landable/migration.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.clear_cache! ⇒ Object
16 17 18 19 |
# File 'lib/landable/migration.rb', line 16 def clear_cache! models.each(&:reset_primary_key) ActiveRecord::Base.connection.schema_cache.clear! end |
.connection_search_path(conn) ⇒ Object
4 5 6 |
# File 'lib/landable/migration.rb', line 4 def connection_search_path(conn) conn.execute('SHOW SEARCH_PATH')[0]['search_path'] end |
.models ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/landable/migration.rb', line 8 def models @models ||= begin classes = Landable.constants.map { |c| "Landable::#{c}".constantize } classes += Landable::Traffic.constants.map { |c| "Landable::Traffic::#{c}".constantize } classes.select { |c| c.is_a?(Class) && c.ancestors.include?(ActiveRecord::Base) } end end |
Instance Method Details
#exec_migration(conn, direction) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/landable/migration.rb', line 22 def exec_migration(conn, direction) # come what may, keep the connection's schema search path intact with_clean_connection(conn) do super end # reset a few things, lest we pollute the way for those who follow self.class.clear_cache! end |