Browse Source

New Rakefile organisation

master
parent
commit
0e94c566b2
  1. 36
      Rakefile
  2. 32
      rubyzome/tasks.rb

36
Rakefile

@ -1,32 +1,4 @@
namespace "db" do
task :std_db_action, [:action] do |t,args|
require 'rubygems'
require 'global_config'
require 'dm-core'
require 'dm-migrations'
# Connect to DB
DataMapper.setup(:default, $db_url)
# Include all models
Dir["app/models/*.rb"].each { |file| require file }
# Reset tables
DataMapper.finalize
if args.action == 'migrate'
DataMapper.auto_migrate!
puts 'migration finished'
elsif args.action == 'upgrade'
DataMapper.auto_upgrade!
puts 'upgrade finished'
else
puts 'std_db_action [migrate|upgrade]'
end
end
task :migrate do
Rake.application.invoke_task("db:std_db_action[migrate]")
end
task :upgrade do
Rake.application.invoke_task("db:std_db_action[upgrade]")
end
end
require 'rubyzome/tasks.rb'
# Uncomment the following line
# to add Rake tasks in app/tasks.rb
# require 'app/tasks.rb'

32
rubyzome/tasks.rb

@ -0,0 +1,32 @@
namespace "db" do
task :std_db_action, [:action] do |t,args|
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'global'
# Connect to DB
DataMapper.setup(:default, $db_url)
# Include all models
Dir["app/models/*.rb"].each { |file| require file }
# Reset tables
DataMapper.finalize
if args.action == 'migrate'
DataMapper.auto_migrate!
puts 'migration finished'
elsif args.action == 'upgrade'
DataMapper.auto_upgrade!
puts 'upgrade finished'
else
puts 'std_db_action [migrate|upgrade]'
end
end
task :migrate do
Rake.application.invoke_task("db:std_db_action[migrate]")
end
task :upgrade do
Rake.application.invoke_task("db:std_db_action[upgrade]")
end
end
Loading…
Cancel
Save