Sha256: 395495bfc84a7620d9f46df4e594b26ce1920f2b652ab4cab0b5b955762ff4d6

Contents?: true

Size: 681 Bytes

Versions: 3

Compression:

Stored size: 681 Bytes

Contents

class MoveTagIntoVclass < ActiveRecord::Migration
  def self.up
    if !$migrating_new_site
      # create a new virtual class for each site and assign all tags to this class.
      Site.find(:all).each do |site|
        VirtualClass.connection.execute("INSERT INTO virtual_classes (name,kpath,real_class,icon,allowed_attributes,create_group_id,site_id) VALUES ('Tag','NPT','Page',NULL,NULL,#{site[:site_group_id]},#{site[:id]})")
        vclass = VirtualClass.find(:first, :conditions=>["site_id = ? AND kpath = 'NPT'",site[:id]])
        Node.connection.execute "UPDATE nodes SET vclass_id = #{vclass[:id]} WHERE kpath = 'NPT'"
      end
    end
  end

  def self.down
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zena-1.0.0.beta3 db/migrate/025_move_tag_into_vclass.rb
zena-1.0.0.beta2 db/migrate/025_move_tag_into_vclass.rb
zena-1.0.0.beta1 db/migrate/025_move_tag_into_vclass.rb