Forks

Revisions

gist: 42524 Download_button fork
public
Public Clone URL: git://gist.github.com/42524.git
Embed All Files: show embed
change_photo_from_attachment_fu_to_paperclip.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class ChangePhotoFromAttachmentFuToPaperclip < ActiveRecord::Migration
  def self.up
    #Reorganise the actual photos on AWS to suit the RWS/Paperclip schema
    #Rename attachement_fu columns to paperclip convention
    rename_column :photos, :filename, :photo_file_name
    rename_column :photos, :content_type, :photo_content_type
    rename_column :photos, :size, :photo_file_size
 
    #Remove non-paperclip columns
    remove_column :photos, :width
    remove_column :photos, :height
    remove_column :photos, :thumbnail
 
    #Remove all child records (attachment_fu)
    Photo.delete_all('parent_id is not null')
    remove_column :photos, :parent_id
  end
end