Class: Migr8::Actions::DeleteAction

Inherits:
Action
  • Object
show all
Defined in:
lib/migr8.rb

Constant Summary collapse

NAME =
"delete"
DESC =
"delete unapplied migration file"
OPTS =
["--Imsure: you must specify this option to delete migration"]
ARGS =
"version ..."

Instance Method Summary collapse

Methods inherited from Action

#cmdopterr, find_by_name, #get_command, inherited, #parse, #parser, #repository, #short_usage, subclasses, #usage

Instance Method Details

#run(options, args) ⇒ Object



1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
# File 'lib/migr8.rb', line 1828

def run(options, args)
  versions = args
  ! args.empty?  or
    raise cmdopterr("#{NAME}: version required.")
  options['Imsure']  or
    raise cmdopterr("#{NAME}: you must specify '--Imsure' option.")
  #
  repo = repository()
  op = RepositoryOperation.new(repo)
  _wrap do
    versions.each do |version|
      print "## deleting '#{repo.migration_filepath(version)}' ... "
      begin
        op.delete(version)
        puts "done."
      rescue Exception => ex
        puts ""
        raise ex
      end
    end
  end
end