Module: SchemaPlus::Views::Middleware::Dumper::Tables
- Defined in:
- lib/schema_plus/views/middleware.rb
Defined Under Namespace
Classes: View
Instance Method Summary collapse
-
#after(env) ⇒ Object
Dump views.
-
#view_index_options(index, connection) ⇒ Object
Take from ActiveRecord::SchemaDumper#index_parts.
Instance Method Details
#after(env) ⇒ Object
Dump views
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/schema_plus/views/middleware.rb', line 8 def after(env) re_view_referent = %r{(?:(?i)FROM|JOIN) \S*\b(\S+)\b} env.connection.views.each do |view_name| next if env.dumper.ignored?(view_name) definition, view_type = env.connection.view_full_definition(view_name) indexes = [] if view_type == :materialized env.connection.indexes(view_name).each do |index| indexes << SchemaPlus::Core::SchemaDump::Table::Index.new( name: index.name, columns: index.columns, options: (index, env.connection) ) end end view = View.new( name: view_name, definition: definition, view_type: view_type, indexes: indexes ) env.dump.tables[view.name] = view env.dump.depends(view.name, view.definition.scan(re_view_referent).flatten) end end |
#view_index_options(index, connection) ⇒ Object
Take from ActiveRecord::SchemaDumper#index_parts
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/schema_plus/views/middleware.rb', line 37 def (index, connection) = {} [:unique] = true if index.unique [:length] = index.lengths if index.lengths.present? [:order] = index.orders if index.orders.present? [:opclass] = index.opclasses if index.opclasses.present? [:where] = index.where if index.where [:using] = index.using if !connection.default_index_type?(index) [:type] = index.type if index.type [:comment] = index.comment if index.comment end |