Sha256: 9302f1cb813701d37c23fe0c25512d625751117079048920ceb28427de2995ea
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
class CreateAlberichEntities < ActiveRecord::Migration class Alberich::Entity < ActiveRecord::Base; end def up create_table :alberich_entities do |t| t.string :name t.references :entity_target, :polymorphic => true, :null => false t.integer :lock_version, :default => 0 t.timestamps end if Alberich.user_class.constantize.table_exists? Alberich.user_class.constantize.all.each do |u| unless u.entity entity = Entity.new(:entity_target => u) entity.name = u.to_s entity.save! end end end if Alberich.user_group_class.constantize.table_exists? Alberich.user_group_class.constantize.all.each do |ug| unless ug.entity entity = Entity.new(:entity_target => ug) entity.name = ug.to_s entity.save! end end end end def down drop_table :alberich_entities end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alberich-0.2.0 | db/migrate/20121027023136_create_alberich_entities.rb |