class AddDataFunctionsReturnItem < ActiveRecord::Migration
  def self.up
    Function.create(:name=>'返品処理',:code=>'return_item',:position=>1002)
    f = Function.find_by_code('return_item')
    Authority.find(:all).each do |auth|
      execute("insert into authorities_functions values(#{auth.id},#{f.id})")
    end
  end

  def self.down
    f = Function.find_by_code('return_item')
    Authority.find(:all).each do |auth|
      execute("delete from authorities_functions where authority_id = #{auth.id} and function_id = #{f.id}")
    end
    f.delete
  end
end
