Module: Torque::PostgreSQL::Adapter::InheritanceStatements
- Included in:
- Torque::PostgreSQL::Adapter
- Defined in:
- lib/torque/postgresql/adapter/inheritance_statements.rb
Constant Summary collapse
- SYNC_MARKER =
Copies created by a sync are named after this, which is how they are told apart from anything written by hand
'sync_inh_'- SYNC_FEATURES =
%i[ primary_key indexes unique_constraints exclusion_constraints foreign_keys ].freeze
Instance Method Summary collapse
-
#sync_inheritance_features(table_name, children = nil, prune: false, **features) ⇒ Object
PostgreSQL only propagates columns, their defaults and their check constraints to inherited tables.
Instance Method Details
#sync_inheritance_features(table_name, children = nil, prune: false, **features) ⇒ Object
PostgreSQL only propagates columns, their defaults and their check
constraints to inherited tables. This copies over everything else that
Rails has a DSL for, from table_name down to its children
Features default to true, so passing one as false excludes it.
Passing any of them as true instead selects only those
Example:
sync_inheritance_features :activities
sync_inheritance_features :activities, %i[activity_books]
sync_inheritance_features :activities, primary_key: false
sync_inheritance_features :activities, prune: true
28 29 30 31 32 33 34 |
# File 'lib/torque/postgresql/adapter/inheritance_statements.rb', line 28 def sync_inheritance_features(table_name, children = nil, prune: false, **features) features = sync_inheritance_selection(features) sync_inheritance_tree(table_name, children).each do |child, parents| sync_inheritance_into(child, parents, features, prune) end end |