This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rails_datamapper] Apply patch from Kristian Meier <m.kristian@web.de>
Signed-off-by: Dan Kubb <dan.kubb@autopilotmarketing.com>
- Loading branch information
Dan Kubb
committed
Apr 17, 2009
1 parent
a9d7779
commit a5f6d69
Showing
7 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace :db do | ||
|
||
desc "Perform automigration" | ||
task :automigrate => :environment do | ||
::DataMapper.auto_migrate! | ||
end | ||
|
||
desc "Perform non destructive automigration" | ||
task :autoupgrade => :environment do | ||
::DataMapper.auto_upgrade! | ||
end | ||
|
||
namespace :migrate do | ||
task :load => :environment do | ||
gem 'dm-migrations' | ||
FileList["db/migrations/*.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' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
class <%= class_name %> | ||
include DataMapper::Resource | ||
property :id, Integer, :serial => true | ||
property :id, Serial | ||
<% for attribute in attributes -%> | ||
property :<%= attribute.name %>, <%= attribute.type.to_s.capitalize %>, :nullable => false | ||
|
||
<% end -%> | ||
<% unless options[:skip_timestamps] %> | ||
property :created_at, DateTime, :nullable => false | ||
property :updated_at, DateTime, :nullable => false | ||
|
||
<% end -%> | ||
end |
1 change: 1 addition & 0 deletions
1
rails_datamapper/generators/rspec_dm_model/rspec_dm_model_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
rails_datamapper/generators/rspec_dm_model/templates/model.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
class <%= class_name %> | ||
include DataMapper::Resource | ||
property :id, Integer, :serial => true | ||
property :id, Serial | ||
<% for attribute in attributes -%> | ||
property :<%= attribute.name %>, <%= attribute.type.to_s.capitalize %>, :nullable => false | ||
|
||
<% end -%> | ||
<% unless options[:skip_timestamps] %> | ||
property :created_at, DateTime, :nullable => false | ||
property :updated_at, DateTime, :nullable => false | ||
|
||
<% end -%> | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit a5f6d69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
michaelklishin: Good question. I must’ve missed that when reviewing the patch. If it is possible to make this work without depending on AR I would prefer it, because people would be able to alter their Rails config so that AR isn’t loaded into memory at all (why load it if you’re not using it?).
Perhaps we should direct comments to here: http://datamapper.lighthouseapp.com/projects/20609/tickets/804-patch-rails_datamapper-get-it-to-run-with-rails-230#ticket-804-2
Is this because generator is tied AR code?