module XMigra::DeclarativeMigration

Constants

DECLARATION_VERSION_KEY
GOAL_KEY
Missing
QUALIFICATION_KEY
SUBDIR
TARGET_KEY
VALID_GOALS

Public Instance Methods

affected_object() click to toggle source
# File lib/xmigra/declarative_migration.rb, line 106
def affected_object
  @declarative_target ||= @all_info[TARGET_KEY].dup.freeze
end
changes() click to toggle source

Override the way the base class handles changes – this integrates with the “history” command

# File lib/xmigra/declarative_migration.rb, line 112
def changes
  if management_migration?
    []
  else
    [affected_object]
  end
end
declarative_file_path() click to toggle source
# File lib/xmigra/declarative_migration.rb, line 142
def declarative_file_path
  @declarative_file_path ||= Pathname(file_path).dirname.join(SUBDIR, affected_object + '.yaml')
end
declarative_status() click to toggle source
# File lib/xmigra/declarative_migration.rb, line 146
def declarative_status
  @declarative_status ||= begin
    vcs_comparator(:expected_content_method=>:implementation_of?).relative_version(declarative_file_path)
  end
end
delta(file_path) click to toggle source
# File lib/xmigra/declarative_migration.rb, line 152
def delta(file_path)
  vcs_changes_from(vcs_latest_revision, file_path)
end
goal() click to toggle source
# File lib/xmigra/declarative_migration.rb, line 100
def goal
  @declarative_goal ||= @all_info[GOAL_KEY].tap do |val|
    raise(ArgumentError, "'#{GOAL_KEY}' must be one of: #{VALID_GOALS.join(', ')}") unless VALID_GOALS.include?(val)
  end.to_sym
end
implementation_of?(file_path) click to toggle source
# File lib/xmigra/declarative_migration.rb, line 138
def implementation_of?(file_path)
  XMigra.secure_digest(file_path.read) == implemented_version
end
implemented_version() click to toggle source

This method is only used when the declarative file has uncommitted modifications and the migration file is uncommitted

# File lib/xmigra/declarative_migration.rb, line 134
def implemented_version
  @declarative_implemented_ver ||= (@all_info[DECLARATION_VERSION_KEY].dup.freeze if vcs_uncommitted?)
end
management_migration?() click to toggle source
# File lib/xmigra/declarative_migration.rb, line 128
def management_migration?
  [:adoption, :renunciation].include? goal
end
questionable?() click to toggle source
# File lib/xmigra/declarative_migration.rb, line 156
def questionable?
  @all_info.has_key? QUALIFICATION_KEY
end
sql() click to toggle source
Calls superclass method
# File lib/xmigra/declarative_migration.rb, line 120
def sql
  if management_migration?
    ''
  else
    super()
  end
end