Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ To avoid any dependency on active record add this to your projects environment.r

config.frameworks -= [ :active_record ]

== Migrations

After generating datamapper rake tasks

script/generate dm_install

following migrations become available:

dm:automigrate
dm:autoupgrade
dm:migrate

== Session Store

Change config/initializers/session_store.rb to something like the following:
Expand Down
23 changes: 13 additions & 10 deletions generators/dm_install/templates/datamapper.rake
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
namespace :db do

namespace :dm do
desc 'Perform automigration'
task :automigrate => :environment do
FileList['app/models/**/*.rb'].each do |model|
load model
end
::DataMapper.auto_migrate!
end

desc 'Perform non destructive automigration'
task :autoupgrade => :environment do
FileList['app/models/**/*.rb'].each do |model|
load model
end
::DataMapper.auto_upgrade!
end

namespace :migrate do
task :load => :environment do
gem 'dm-migrations', '0.10.3'
FileList['db/migrations/*.rb'].each do |migration|
gem 'dm-migrations'
require 'dm-migrations/migration_runner'
FileList['db/migrate/*.rb'].each do |migration|
load migration
end
end

desc 'Migrate up using migrations'
task :up, :version, :needs => :load do |t, args|
version = args[:version]
migrate_up!(version)
end

desc 'Migrate down using migrations'
task :down, :version, :needs => :load do |t, args|
version = args[:version]
migrate_down!(version)
end
end

desc 'Migrate the database to the latest version'
task :migrate => 'db:migrate:up'
task :migrate => 'dm:migrate:up'

end