Permalink
Browse files

Adding the migration helper from Ben Wyrosdick.

  • Loading branch information...
1 parent 3c1ddd5 commit 4e53b88b7676cfd92aace252dbb5672b22f993c9 @delynn delynn committed Apr 5, 2008
Showing with 25 additions and 3 deletions.
  1. +4 −2 CHANGELOG
  2. +2 −1 init.rb
  3. +19 −0 lib/migration_helper.rb
View
@@ -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])
View
@@ -1,3 +1,4 @@
require 'stamper'
require 'stampable'
-require 'userstamp'
+require 'userstamp'
+require 'migration_helper'
View
@@ -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.