Skip to content

Commit

Permalink
Adding the migration helper from Ben Wyrosdick.
Browse files Browse the repository at this point in the history
  • Loading branch information
delynn committed Apr 5, 2008
1 parent 3c1ddd5 commit 4e53b88
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
2.0 (2-17-2008)
* [Marshall Roch] - Stamping can be temporarily turned off using the 'without_stamps' class
method.
* [Ben Wyrosdick] - Added a migration helper that gives migration scripts a <tt>userstamps</tt>
method.
* [Marshall Roch] - Stamping can be temporarily turned off using the 'without_stamps' class
method.
Example:
Post.without_stamps do
post = Post.find(params[:id])
Expand Down
3 changes: 2 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'stamper'
require 'stampable'
require 'userstamp'
require 'userstamp'
require 'migration_helper'
19 changes: 19 additions & 0 deletions lib/migration_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Ddb
module Userstamp
module MigrationHelper
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
end

module InstanceMethods
def userstamps(include_deleted_by = false)
column(Ddb::Userstamp.compatibility_mode ? :created_by : :creator_id, :integer)
column(Ddb::Userstamp.compatibility_mode ? :updated_by : :updater_id, :integer)
column(Ddb::Userstamp.compatibility_mode ? :deleted_by : :deleter_id, :integer) if include_deleted_by
end
end
end
end
end

ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Ddb::Userstamp::MigrationHelper)

0 comments on commit 4e53b88

Please sign in to comment.