Module: SchemaPlus::ActiveRecord::SchemaDumper

Includes:
TSort
Defined in:
lib/schema_plus/active_record/schema_dumper.rb

Overview

SchemaPlus modifies ActiveRecord's schema dumper to include foreign key constraints and views.

Additionally, index and foreign key constraint definitions are dumped inline in the create_table block. (This is done for elegance, but also because Sqlite3 does not allow foreign key constraints to be added to a table after it has been defined.)

The tables and views are dumped in alphabetical order, subject to topological sort constraints that a table must be dumped before any view that references it or table that has a foreign key constaint to it.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:


23
24
25
26
27
28
29
30
31
# File 'lib/schema_plus/active_record/schema_dumper.rb', line 23

def self.included(base) #:nodoc:
  base.class_eval do
    private
    alias_method_chain :table, :schema_plus
    alias_method_chain :tables, :schema_plus
    alias_method_chain :indexes, :schema_plus
    alias_method_chain :foreign_keys, :schema_plus if private_method_defined? :foreign_keys
  end
end