Module: ActiveRecordSchema::SchemaDiff
- Extended by:
- ActiveSupport::Concern
- Included in:
- Schema
- Defined in:
- lib/active_record_schema/schema_diff.rb
Instance Method Summary collapse
- #_column_names ⇒ Object
- #_connection ⇒ Object
- #_diff_fields_add ⇒ Object
- #_diff_indexes_add ⇒ Object
- #_diff_joins_add ⇒ Object
- #_index_names ⇒ Object
- #_table ⇒ Object
- #_table_names ⇒ Object
- #diff(*args) ⇒ Object
Instance Method Details
#_column_names ⇒ Object
31 32 33 |
# File 'lib/active_record_schema/schema_diff.rb', line 31 def _column_names _connection.columns(_table).map(&:name) end |
#_connection ⇒ Object
23 24 25 |
# File 'lib/active_record_schema/schema_diff.rb', line 23 def _connection ActiveRecord::Base.connection end |
#_diff_fields_add ⇒ Object
10 11 12 |
# File 'lib/active_record_schema/schema_diff.rb', line 10 def _diff_fields_add model.schema.fields.values.delete_if {|field| _column_names.include?(field.name.to_s) } end |
#_diff_indexes_add ⇒ Object
14 15 16 |
# File 'lib/active_record_schema/schema_diff.rb', line 14 def _diff_indexes_add model.schema.indexes.values.delete_if {|index| _index_names.include?(index.name.to_s) } end |
#_diff_joins_add ⇒ Object
18 19 20 |
# File 'lib/active_record_schema/schema_diff.rb', line 18 def _diff_joins_add model.schema.joins.values.delete_if {|join| _table_names.include?(join.table.to_s) } end |
#_index_names ⇒ Object
35 36 37 |
# File 'lib/active_record_schema/schema_diff.rb', line 35 def _index_names _connection.indexes(_table).map(&:name) end |
#_table ⇒ Object
27 28 29 |
# File 'lib/active_record_schema/schema_diff.rb', line 27 def _table model.table_name end |
#_table_names ⇒ Object
39 40 41 |
# File 'lib/active_record_schema/schema_diff.rb', line 39 def _table_names _connection.tables end |
#diff(*args) ⇒ Object
5 6 7 8 |
# File 'lib/active_record_schema/schema_diff.rb', line 5 def diff(*args) diff_method = "_diff_" << args.join('_') self.respond_to?(diff_method) ? self.send(diff_method) : [] end |