Class: Webhookdb::Replicator::SchemaModification
- Inherits:
-
Object
- Object
- Webhookdb::Replicator::SchemaModification
- Defined in:
- lib/webhookdb/replicator/schema_modification.rb
Instance Attribute Summary collapse
-
#application_database_statements ⇒ Array<String>
readonly
Each of these statements are executed in the application database, NOT whatever database the schema modification itself is executed against.
-
#nontransaction_statements ⇒ Array<String>
readonly
Each of these statements must be executed one-at-a-time.
-
#transaction_statements ⇒ Array<String>
readonly
All of these statements can be sent to the server at once.
Instance Method Summary collapse
- #execute(db) ⇒ Object
-
#initialize ⇒ SchemaModification
constructor
A new instance of SchemaModification.
- #noop? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ SchemaModification
Returns a new instance of SchemaModification.
16 17 18 19 20 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 16 def initialize @transaction_statements = [] @nontransaction_statements = [] @application_database_statements = [] end |
Instance Attribute Details
#application_database_statements ⇒ Array<String> (readonly)
Each of these statements are executed in the application database, NOT whatever database the schema modification itself is executed against.
14 15 16 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 14 def application_database_statements @application_database_statements end |
#nontransaction_statements ⇒ Array<String> (readonly)
Each of these statements must be executed one-at-a-time. An example would be creating indices concurrently in PG.
10 11 12 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 10 def nontransaction_statements @nontransaction_statements end |
#transaction_statements ⇒ Array<String> (readonly)
All of these statements can be sent to the server at once.
6 7 8 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 6 def transaction_statements @transaction_statements end |
Instance Method Details
#execute(db) ⇒ Object
28 29 30 31 32 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 28 def execute(db) db << stmt2str(@transaction_statements) @nontransaction_statements.each { |stmt| db << stmt } Webhookdb::Postgres::Model.db << stmt2str(@application_database_statements) end |
#noop? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 22 def noop? return @transaction_statements.empty? && @nontransaction_statements.empty? && @application_database_statements.empty? end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/webhookdb/replicator/schema_modification.rb', line 39 def to_s return [stmt2str(@transaction_statements), stmt2str(@nontransaction_statements)].reject(&:blank?).join("\n") end |