Class: DatabasePatcher::Action::PatchApplier

Inherits:
DatabasePatcher::Action show all
Defined in:
lib/database_patcher/action/patch_applier.rb

Instance Attribute Summary

Attributes inherited from DatabasePatcher::Action

#interface

Instance Method Summary collapse

Methods inherited from DatabasePatcher::Action

#initialize

Constructor Details

This class inherits a constructor from DatabasePatcher::Action

Instance Method Details

#downObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/database_patcher/action/patch_applier.rb', line 13

def down
  return unless interface.ask('This will execute all the down patches! Are you sure?')
  connection = DatabasePatcher::DB.create_connection
  connection.transaction do
    fetcher = DatabasePatcher::Fetcher.new(connection, interface)
    fetcher.get_intalled_patches.each do |installed_patche|
      installed_patche.down(connection)
    end
  end
end

#rollbackObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/database_patcher/action/patch_applier.rb', line 24

def rollback
  return unless interface.ask('This will execute the last patch down part! Are you sure?')
  connection = DatabasePatcher::DB.create_connection
  connection.transaction do
    fetcher = DatabasePatcher::Fetcher.new(connection, interface)
    fetcher.get_intalled_patches.each do |patch|
      patch.down(connection)
      break
    end
  end
end

#upObject



3
4
5
6
7
8
9
10
11
# File 'lib/database_patcher/action/patch_applier.rb', line 3

def up
  connection = DatabasePatcher::DB.create_connection
  connection.transaction do
    fetcher = DatabasePatcher::Fetcher.new(connection, interface)
    fetcher.get_pending_patches.each do |pending_patch|
      pending_patch.up(connection)
    end
  end
end