module ActiveRecordSchema::SchemaDiff

Public Instance Methods

_column_names() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 43
def _column_names
  _table_exists? ? _connection.columns(_table).map(&:name) : []
end
_connection() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 34
def _connection
  ActiveRecord::Base.connection
end
_diff_fields_add() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 22
def _diff_fields_add
  model.schema.fields.values.delete_if {|field| _column_names.include?(field.name.to_s) }
end
_diff_indexes_add() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 26
def _diff_indexes_add
  model.schema.indexes.values.delete_if {|index| _index_exists?(index.name) }
end
_diff_joins_add() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 30
def _diff_joins_add
  model.schema.joins.values.delete_if {|join| _table_names.include?(join.table.to_s) }
end
_index_exists?(columns) click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 55
def _index_exists?(columns)
  _connection.index_exists?(_table, columns)      
end
_table() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 38
def _table
  # prefix = model.parents.find {|p| p.respond_to?(:table_name_prefix)}.try(:table_name_prefix)
  model.table_name
end
_table_exists?() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 51
def _table_exists?
  _connection.table_exists?(_table)
end
_table_names() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 47
def _table_names
  _connection.tables
end
diff(*args) click to toggle source
# 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
nothing_to_do?() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 10
def nothing_to_do?
  table_exists? && diff(:fields, :add).empty? && diff(:indexes, :add).empty? && diff(:joins, :add).empty? 
end
prefixed_table_name() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 18
def prefixed_table_name
  _table
end
table_exists?() click to toggle source
# File lib/active_record_schema/schema_diff.rb, line 14
def table_exists?
  _table_exists?
end