--- /dev/null
+class AddDataFunctionsSupplier < ActiveRecord::Migration
+ def self.up
+ Function.create(:name=>'仕入先マスタ',:code=>'supplier',:position=>1000)
+ f = Function.find_by_code('supplier')
+ 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('supplier')
+ 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
+++ /dev/null
-class AddDataFunctionsVer2 < ActiveRecord::Migration
- def self.up
- Function.delete_all
- Authority.delete_all
- execute("delete from authorities_functions")
-
-
- directory = File.join(File.dirname(__FILE__), "fixed_data")
- Fixtures.create_fixtures(directory, "authorities")
- Fixtures.create_fixtures(directory, "functions")
- Fixtures.create_fixtures(directory, "authorities_functions")
- end
-
- def self.down
- Function.delete_all
- execute("delete from authorities_functions")
- Authority.delete_all
- end
-end
--- /dev/null
+class AddDataFunctionsStock < ActiveRecord::Migration
+ def self.up
+ Function.create(:name=>'在庫管理',:code=>'stock',:position=>1001)
+ f = Function.find_by_code('stock')
+ 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('stock')
+ 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
+++ /dev/null
-class AddDataFunctionsVer3 < ActiveRecord::Migration
- def self.up
- Function.delete_all
- Authority.delete_all
- execute("delete from authorities_functions")
-
-
- directory = File.join(File.dirname(__FILE__), "fixed_data")
- Fixtures.create_fixtures(directory, "authorities")
- Fixtures.create_fixtures(directory, "functions")
- Fixtures.create_fixtures(directory, "authorities_functions")
- end
-
- def self.down
- Function.delete_all
- execute("delete from authorities_functions")
- Authority.delete_all
- end
-end
1,33\r
1,34\r
1,40\r
-1,41\r
-1,42\r
name: メンバー管理\r
code: "member"\r
position: 900\r
-F901:\r
- id: 41\r
- name: 仕入先マスタ\r
- code: "supplier"\r
- position: 901\r
-F902:\r
- id: 42\r
- name: 在庫管理\r
- code: "stock"\r
- position: 902
\ No newline at end of file