Sha256: 5ae0c6e3875108d69836f7f3e25303ab0e0cb26726e05fe6d3e209c2b5d7b574

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

# This migration comes from alchemy (originally 20160422195310)
class AddImageFileFormatToAlchemyPictures < ActiveRecord::Migration[4.2]
  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-4.2.0 spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb
alchemy-devise-4.1.0 spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb
alchemy-devise-4.1.0.beta spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb
alchemy-devise-4.0.0 spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb