Class: SchemaEvolutionManager::BaselineUtil
- Inherits:
-
Object
- Object
- SchemaEvolutionManager::BaselineUtil
- Defined in:
- lib/schema-evolution-manager/baseline_util.rb
Instance Method Summary collapse
-
#apply!(dir) ⇒ Object
Applies scripts in order, returning number of scripts applied.
- #dry_run? ⇒ Boolean
-
#initialize(db, opts = {}) ⇒ BaselineUtil
constructor
A new instance of BaselineUtil.
Constructor Details
#initialize(db, opts = {}) ⇒ BaselineUtil
Returns a new instance of BaselineUtil.
5 6 7 8 9 10 11 12 13 |
# File 'lib/schema-evolution-manager/baseline_util.rb', line 5 def initialize(db, opts={}) @dry_run = opts.delete(:dry_run) if @dry_run.nil? @dry_run = true end @db = Preconditions.assert_class(db, Db) @scripts = Scripts.new(@db, Scripts::SCRIPTS) end |
Instance Method Details
#apply!(dir) ⇒ Object
Applies scripts in order, returning number of scripts applied
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/schema-evolution-manager/baseline_util.rb', line 20 def apply!(dir) Preconditions.check_state(File.directory?(dir), "Dir[%s] does not exist" % dir) count = 0 @scripts.each_pending(dir) do |filename, path| count += 1 if @dry_run puts "[DRY RUN] Baselining #{filename}" apply_dry_run(filename, path) else puts "Baselining #{filename}" apply_real(filename, path) end end count end |
#dry_run? ⇒ Boolean
15 16 17 |
# File 'lib/schema-evolution-manager/baseline_util.rb', line 15 def dry_run? @dry_run end |