Class: Mammoth::Sources::PostgresPublicationTable
- Inherits:
-
Object
- Object
- Mammoth::Sources::PostgresPublicationTable
- Defined in:
- lib/mammoth/sources/postgres_publication_inspector.rb
Overview
Immutable replica-identity facts for one table in configured publications.
Instance Attribute Summary collapse
-
#primary_key_usable ⇒ Object
readonly
Returns the value of attribute primary_key_usable.
-
#publishes_deletes ⇒ Object
readonly
Returns the value of attribute publishes_deletes.
-
#publishes_updates ⇒ Object
readonly
Returns the value of attribute publishes_updates.
-
#relation_id ⇒ Object
readonly
Returns the value of attribute relation_id.
-
#replica_identity ⇒ Object
readonly
Returns the value of attribute replica_identity.
-
#replica_identity_columns ⇒ Object
readonly
Returns the value of attribute replica_identity_columns.
-
#replica_identity_index_usable ⇒ Object
readonly
Returns the value of attribute replica_identity_index_usable.
-
#schema_name ⇒ Object
readonly
Returns the value of attribute schema_name.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
-
#identity_actions ⇒ Array<String>
Publication actions that require old-row identity.
-
#identity_required? ⇒ Boolean
Whether any configured publication requires replica identity.
-
#identity_usable? ⇒ Boolean
Whether PostgreSQL can identify old rows for the published actions.
- #initialize(relation_id:, schema_name:, table_name:, publishes_updates:, publishes_deletes:, replica_identity:, replica_identity_columns:, primary_key_usable:, replica_identity_index_usable:) ⇒ void constructor
-
#qualified_name ⇒ String
Schema-qualified table name for diagnostics.
Constructor Details
#initialize(relation_id:, schema_name:, table_name:, publishes_updates:, publishes_deletes:, replica_identity:, replica_identity_columns:, primary_key_usable:, replica_identity_index_usable:) ⇒ void
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 13 def initialize(relation_id:, schema_name:, table_name:, publishes_updates:, publishes_deletes:, replica_identity:, replica_identity_columns:, primary_key_usable:, replica_identity_index_usable:) @relation_id = relation_id @schema_name = schema_name @table_name = table_name @publishes_updates = publishes_updates @publishes_deletes = publishes_deletes @replica_identity = replica_identity @replica_identity_columns = replica_identity_columns.freeze @primary_key_usable = primary_key_usable @replica_identity_index_usable = replica_identity_index_usable freeze end |
Instance Attribute Details
#primary_key_usable ⇒ Object (readonly)
Returns the value of attribute primary_key_usable.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def primary_key_usable @primary_key_usable end |
#publishes_deletes ⇒ Object (readonly)
Returns the value of attribute publishes_deletes.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def publishes_deletes @publishes_deletes end |
#publishes_updates ⇒ Object (readonly)
Returns the value of attribute publishes_updates.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def publishes_updates @publishes_updates end |
#relation_id ⇒ Object (readonly)
Returns the value of attribute relation_id.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def relation_id @relation_id end |
#replica_identity ⇒ Object (readonly)
Returns the value of attribute replica_identity.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def replica_identity @replica_identity end |
#replica_identity_columns ⇒ Object (readonly)
Returns the value of attribute replica_identity_columns.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def replica_identity_columns @replica_identity_columns end |
#replica_identity_index_usable ⇒ Object (readonly)
Returns the value of attribute replica_identity_index_usable.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def replica_identity_index_usable @replica_identity_index_usable end |
#schema_name ⇒ Object (readonly)
Returns the value of attribute schema_name.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def schema_name @schema_name end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
9 10 11 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 9 def table_name @table_name end |
Instance Method Details
#identity_actions ⇒ Array<String>
Publication actions that require old-row identity.
38 39 40 41 42 43 44 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 38 def identity_actions actions = [] # : Array[String] actions.tap do actions << "UPDATE" if publishes_updates actions << "DELETE" if publishes_deletes end end |
#identity_required? ⇒ Boolean
Whether any configured publication requires replica identity.
49 50 51 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 49 def identity_required? publishes_updates || publishes_deletes end |
#identity_usable? ⇒ Boolean
Whether PostgreSQL can identify old rows for the published actions.
d uses a primary key, i uses a selected replica-identity index,
and f logs the full old row. n provides no old-row identity.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 59 def identity_usable? return true unless identity_required? case replica_identity when "d" then primary_key_usable when "i" then replica_identity_index_usable when "f" then true else false end end |
#qualified_name ⇒ String
Schema-qualified table name for diagnostics.
31 32 33 |
# File 'lib/mammoth/sources/postgres_publication_inspector.rb', line 31 def qualified_name "#{schema_name}.#{table_name}" end |