cirandas.net

ref: master

db/migrate/020_create_thumbnails.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class CreateThumbnails < ActiveRecord::Migration
  def self.up
    create_table :thumbnails do |t|
      # attachment_fu data for all uploaded files
      t.column :size,         :integer  # file size in bytes
      t.column :content_type, :string   # mime type, ex: application/mp3
      t.column :filename,     :string   # sanitized filename

      # attachment_fu data for images
      t.column :height,       :integer  # in pixels
      t.column :width,        :integer  # in pixels

      # attachment_fu data for thumbnails
      t.column :parent_id,    :integer  # id of parent image (on the same table, a self-referencing foreign-key).
      t.column :thumbnail,    :string   # the 'type' of thumbnail this attachment record describes.
    end
  end

  def self.down
    drop_table :thumbnails
  end
end