Class: Vcs4sql::Sqlite::Expected
- Inherits:
-
Object
- Object
- Vcs4sql::Sqlite::Expected
- Defined in:
- lib/vcs4sql/sqlite/expected.rb
Overview
The expected database change log. Contains all changes which should be applied to target database.
Instance Method Summary collapse
-
#apply_all(conn) ⇒ Object
Apply all sql files one by one.
-
#apply_mismatch(existing, conn) ⇒ Object
Apply sql files which weren’t applied yet.
-
#initialize(home, testdata) ⇒ Expected
constructor
A new instance of Expected.
Constructor Details
#initialize(home, testdata) ⇒ Expected
Returns a new instance of Expected.
32 33 34 35 |
# File 'lib/vcs4sql/sqlite/expected.rb', line 32 def initialize(home, testdata) @home = home @nonprod = ->(f) { !testdata && (f.to_s.end_with? ".testdata.sql") } end |
Instance Method Details
#apply_all(conn) ⇒ Object
Apply all sql files one by one
39 40 41 |
# File 'lib/vcs4sql/sqlite/expected.rb', line 39 def apply_all(conn) apply(-1, conn) end |
#apply_mismatch(existing, conn) ⇒ Object
Apply sql files which weren’t applied yet
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vcs4sql/sqlite/expected.rb', line 45 def apply_mismatch(existing, conn) version = -1 changelog.each_with_index do |change, i| break if existing.absent(i) unless change.matches existing.change(i) raise ChecksumMismatchError.new change, existing.change(i) end version = i end apply(version, conn) end |