Class: Veksel::Commands::Fork
- Inherits:
-
Object
- Object
- Veksel::Commands::Fork
- Defined in:
- lib/veksel/commands/fork.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#source_db ⇒ Object
readonly
Returns the value of attribute source_db.
-
#target_db ⇒ Object
readonly
Returns the value of attribute target_db.
Instance Method Summary collapse
-
#initialize(db) ⇒ Fork
constructor
A new instance of Fork.
- #perform ⇒ Object
Constructor Details
#initialize(db) ⇒ Fork
Returns a new instance of Fork.
6 7 8 9 10 11 |
# File 'lib/veksel/commands/fork.rb', line 6 def initialize(db) @adapter = Veksel.adapter_for(db.configuration_hash) @source_db = adapter.main_database @target_db = adapter.db_name_for_suffix(Veksel.suffix) raise "Source and target databases cannot be the same" if source_db == target_db end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
4 5 6 |
# File 'lib/veksel/commands/fork.rb', line 4 def adapter @adapter end |
#source_db ⇒ Object (readonly)
Returns the value of attribute source_db.
4 5 6 |
# File 'lib/veksel/commands/fork.rb', line 4 def source_db @source_db end |
#target_db ⇒ Object (readonly)
Returns the value of attribute target_db.
4 5 6 |
# File 'lib/veksel/commands/fork.rb', line 4 def target_db @target_db end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/veksel/commands/fork.rb', line 13 def perform return false unless adapter return false if adapter.target_populated?(target_db) adapter.kill_connection(source_db) adapter.create_database(target_db, template: source_db) true end |