Sha256: 0f117b36f39cb2555739f247cb89e107a941ddf4ed5030a86e425533da648281

Contents?: true

Size: 685 Bytes

Versions: 4

Compression:

Stored size: 685 Bytes

Contents

# This migration comes from alchemy (originally 20160422195310)
class AddImageFileFormatToAlchemyPictures < ActiveRecord::Migration
  def up
    add_column :alchemy_pictures, :image_file_format, :string

    say_with_time "Storing file format of existing pictures" do
      Alchemy::Picture.all.each do |pic|
        begin
          format = pic.image_file.identify('-ping -format "%m"')
          pic.update_column('image_file_format', format.to_s.downcase)
        rescue Dragonfly::Job::Fetch::NotFound => e
          say(e.message, true)
        end
      end
      Alchemy::Picture.count
    end
  end

  def down
    remove_column :alchemy_pictures, :image_file_format
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alchemy-devise-3.6.0 spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb
alchemy-devise-3.5.0 spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb
alchemy-devise-3.5.0.beta spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb
alchemy-devise-3.4.0 spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb