2 desc "Migrate schema to version 0 and back up again. WARNING: Destroys all data in tables!!"
3 task :remigrate => :environment do
4 require 'highline/import'
5 if ENV['OVERWRITE'].to_s.downcase == 'true' or agree("This task will destroy any data in the database. Are you sure you want to \ncontinue? [yn] ")
8 ActiveRecord::Migrator.migrate("#{RADIANT_ROOT}/db/migrate/", 0)
11 Rake::Task["db:migrate"].invoke
14 Rake::Task["db:schema:dump"].invoke
21 desc "Bootstrap your database for Radiant."
22 task :bootstrap => :remigrate do
23 require 'radiant/setup'
24 Radiant::Setup.bootstrap(
25 :admin_name => ENV['ADMIN_NAME'],
26 :admin_username => ENV['ADMIN_USERNAME'],
27 :admin_password => ENV['ADMIN_PASSWORD'],
28 :database_template => ENV['DATABASE_TEMPLATE']
33 # The following tasks are only needed by Scenarios until Rails 2
36 desc 'Drops the database for the current RAILS_ENV'
37 task :drop => :environment do
38 config = ActiveRecord::Base.configurations[RAILS_ENV]
39 case config['adapter']
41 ActiveRecord::Base.connection.drop_database config['database']
43 FileUtils.rm_f(File.join(RAILS_ROOT, config['database']))
45 `dropdb "#{config['database']}"`
49 desc 'Create the database defined in config/database.yml for the current RAILS_ENV'
50 task :create => :environment do
51 config = ActiveRecord::Base.configurations[RAILS_ENV]
53 ActiveRecord::Base.establish_connection(config)
54 ActiveRecord::Base.connection
56 case config['adapter']
58 `mysqladmin #{config['password'].nil? ? '' : "-p #{config['password']}"} -u #{config['username']} create #{config['database']}`
60 `createdb "#{config['database']}" -E utf8`
62 `sqlite "#{config['database']}"`
64 `sqlite3 "#{config['database']}"`
67 p "#{config['database']} already exists"
71 desc "Drops and recreates the database from db/schema.rb for the current environment."
72 task :reset => ['db:drop', 'db:create', 'db:schema:load']