Skip to content

Commit

Permalink
Shorten migration roll-back also
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Mahotkin authored and Jon Yurek committed Apr 20, 2011
1 parent c0b4626 commit e63549c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/paperclip/railtie.rb
Expand Up @@ -20,6 +20,7 @@ class Railtie
def self.insert
ActiveRecord::Base.send(:include, Paperclip::Glue)
File.send(:include, Paperclip::Upfile)
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema)
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema)
end
Expand Down
7 changes: 7 additions & 0 deletions lib/paperclip/schema.rb
Expand Up @@ -6,5 +6,12 @@ def has_attached_file(name)
column :"#{name}_file_size", :integer
column :"#{name}_updated_at", :datetime
end

def drop_attached_file(table_name, name)
remove_column table_name, :"#{name}_file_name"
remove_column table_name, :"#{name}_content_type"
remove_column table_name, :"#{name}_file_size"
remove_column table_name, :"#{name}_updated_at"
end
end
end

0 comments on commit e63549c

Please sign in to comment.