Class: Mighost::Rollbacker
- Inherits:
-
Object
- Object
- Mighost::Rollbacker
- Defined in:
- lib/mighost/rollbacker.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#recovery_source ⇒ Object
readonly
Returns the value of attribute recovery_source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #can_rollback? ⇒ Boolean
-
#initialize(version) ⇒ Rollbacker
constructor
A new instance of Rollbacker.
- #rollback! ⇒ Object
Constructor Details
#initialize(version) ⇒ Rollbacker
Returns a new instance of Rollbacker.
14 15 16 17 |
# File 'lib/mighost/rollbacker.rb', line 14 def initialize(version) @version = version.to_s load_recovery_data end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/mighost/rollbacker.rb', line 12 def content @content end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
12 13 14 |
# File 'lib/mighost/rollbacker.rb', line 12 def filename @filename end |
#recovery_source ⇒ Object (readonly)
Returns the value of attribute recovery_source.
12 13 14 |
# File 'lib/mighost/rollbacker.rb', line 12 def recovery_source @recovery_source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/mighost/rollbacker.rb', line 12 def version @version end |
Class Method Details
.rollback_version!(version) ⇒ Object
108 109 110 |
# File 'lib/mighost/rollbacker.rb', line 108 def rollback_version!(version) new(version).rollback! end |
Instance Method Details
#can_rollback? ⇒ Boolean
33 34 35 |
# File 'lib/mighost/rollbacker.rb', line 33 def can_rollback? content.present? end |
#rollback! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mighost/rollbacker.rb', line 19 def rollback! raise SnapshotNotFound, "No snapshot or git recovery found for version #{version}" unless can_rollback? temp_file = write_temp_migration begin load_and_execute_down(temp_file) remove_from_schema_migrations Snapshot.delete_by_version(version) if recovery_source == :snapshot ensure temp_file.close temp_file.unlink end end |