Exception: Vcs4sql::ChecksumMismatchError

Inherits:
Vcs4sqlError
  • Object
show all
Defined in:
lib/vcs4sql/exception.rb

Instance Attribute Summary

Attributes inherited from Vcs4sqlError

#code

Instance Method Summary collapse

Constructor Details

#initialize(expected, applied) ⇒ ChecksumMismatchError

Returns a new instance of ChecksumMismatchError.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vcs4sql/exception.rb', line 34

def initialize(expected, applied)
  msg = <<~MSG
    Version '#{expected.version}' has checksum mismatch.

    The possible root cause is that the file with migration, which was applied already, got changed recently.
    As a workaround, you may change the md5sum in the database in case if these changes are minor
    and don't affect the structure:
    update changelog set md5sum='#{expected.md5sum}' where id=#{applied.id}

    In case if changes are major and affect the database structure then they should be reverted
    and introduce it as a new change.

    Expected '#{expected.version}' version from '#{expected.file}' (#{expected.md5sum}) has SQL:
    #{expected.sql}
    .............................................................................................
    Existing '#{applied.version}' version from '#{applied.file}' (#{applied.md5sum}) has SQL:
    #{applied.sql}
    .............................................................................................
  MSG
  super("vcs4sql-001", msg)
end