module Prick module Migra def self.migrate(from_name, to_name, file) args = urls(from_name, to_name).join(" ") options = OPTIONS.join(" ") Command.command %( status=0 migra #{options} #{args} >#{file} || { status=$?; } [ $status = 2 ] || exit 1 ) end private OPTIONS = %w(--unsafe --with-privileges) def self.urls(*args) args = Array(args).flatten args.map { |name| "postgresql:///#{name}" } end end end