Sha256: ef8151cc95a0f25b46d558757e1a3c626783a23c3723c811d054ca54a80bfdae

Contents?: true

Size: 621 Bytes

Versions: 2

Compression:

Stored size: 621 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.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

2 entries across 2 versions & 1 rubygems

Version Path
alchemy_cms-3.4.0 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb
alchemy_cms-3.4.0.rc1 db/migrate/20160422195310_add_image_file_format_to_alchemy_pictures.rb