Class: Vcs4sql::Sqlite::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/vcs4sql/sqlite/migration.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Migration

Returns a new instance of Migration.



41
42
43
44
45
# File 'lib/vcs4sql/sqlite/migration.rb', line 41

def initialize(file)
  FileUtils.mkdir_p File.dirname(file)
  @conn = SQLite3::Database.new file
  @conn.results_as_hash = true
end

Instance Method Details

#upgrade(home, testdata = false) ⇒ Object

Parameters:

  • home
  • testdata (defaults to: false)


49
50
51
52
53
54
55
56
57
58
# File 'lib/vcs4sql/sqlite/migration.rb', line 49

def upgrade(home, testdata=false)
  install_vcs4sql
  existing = Applied.new @conn
  expected = Expected.new home, testdata
  if existing.empty?
    expected.apply_all @conn
  else
    expected.apply_mismatch existing, @conn
  end
end