Sha256: 50c77fb9a666c0508f4e93f241f5bbda034a6cb039dae1be0499ade670ffe07a

Contents?: true

Size: 627 Bytes

Versions: 8

Compression:

Stored size: 627 Bytes

Contents

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.chomp.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

8 entries across 8 versions & 1 rubygems

Version Path
alchemy_cms-3.6.1 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-4.0.0.beta db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.6.0 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.5.0 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.4.2 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.5.0.rc2 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.5.0.rc1 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.4.1 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb