Class: DatabasePatcher::PatchEntity::Folder

Inherits:
DatabasePatcher::PatchEntity show all
Defined in:
lib/database_patcher/patch_entity/folder.rb

Instance Method Summary collapse

Methods inherited from DatabasePatcher::PatchEntity

#accepted_extensions, #execute_file, #extract_comments, factory, #get_comment, #initialize, #md5, #patch_record, #raise_unknown_extension_for, #register_this_patch, #timestamp, #uniq_indentifier, #unregister_this_patch

Constructor Details

This class inherits a constructor from DatabasePatcher::PatchEntity

Instance Method Details

#commentObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/database_patcher/patch_entity/folder.rb', line 21

def comment
  comments = []

  up_comment = get_comment(file_path_for('up'))
  down_comment = get_comment(file_path_for('down'))

  if up_comment != ''
    comments << 'UP:'
    comments << up_comment
  end

  if down_comment != ''
    comments << "" if up_comment != ''
    comments << 'DOWN:'
    comments << down_comment
  end

  comments.join("\n")
end

#down(connection) ⇒ Object



8
9
10
11
# File 'lib/database_patcher/patch_entity/folder.rb', line 8

def down(connection)
  execute_from_folder('down', connection)
  unregister_this_patch(connection)
end

#md5_downObject



17
18
19
# File 'lib/database_patcher/patch_entity/folder.rb', line 17

def md5_down
  md5(::File.read(file_path_for('down')))
end

#md5_upObject



13
14
15
# File 'lib/database_patcher/patch_entity/folder.rb', line 13

def md5_up
  md5(::File.read(file_path_for('up')))
end

#up(connection) ⇒ Object



3
4
5
6
# File 'lib/database_patcher/patch_entity/folder.rb', line 3

def up(connection)
  execute_from_folder('up', connection)
  register_this_patch(connection)
end