Sha256: f944ab66e65d53763b7b2f955cf9b15bbec58c6fda6f56daac292a855b89a492

Contents?: true

Size: 516 Bytes

Versions: 13

Compression:

Stored size: 516 Bytes

Contents

class RemoveIconField < ActiveRecord::Migration
  def self.up
    if Role.column_names.include?('icon')
      native_key = :icon
      prop_key   = 'icon'
      Role.all.each do |rec|
        next unless value = rec[native_key]
        prop  = rec.prop
        prop[prop_key] = value
        Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
      end
      remove_column :roles, :icon
    end
  end

  def self.down
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
zena-1.2.8 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.7 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.6 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.5 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.4 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.3 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.2 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.1 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.2.0 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.1.3 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.1.2 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.1.1 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb
zena-1.1.0 bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb