Sha256: 68992fb145fbce68a19fe94df70e35b252640f1c63d68f231b6beb008009e094

Contents?: true

Size: 787 Bytes

Versions: 16

Compression:

Stored size: 787 Bytes

Contents

class RolifyCreate<%= role_cname.pluralize.camelize %> < ActiveRecord::Migration
  def change
    create_table(:<%= role_cname.tableize %>) do |t|
      t.string :name
      t.references :resource, :polymorphic => true

      t.timestamps
    end

    create_table(:<%= (user_cname.tableize + "_" + role_cname.tableize) %>, :id => false) do |t|
      t.references :<%= user_cname.underscore.singularize %>
      t.references :<%= role_cname.underscore.singularize %>
    end

    add_index(:<%= role_cname.tableize %>, :name)
    add_index(:<%= role_cname.tableize %>, [ :name, :resource_type, :resource_id ])
    add_index(:<%= "#{user_cname.tableize}_#{role_cname.tableize}" %>, [ :<%= user_cname.underscore.singularize %>_id, :<%= role_cname.underscore.singularize %>_id ])
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rolify-3.3.0.rc2 lib/generators/rolify/role/templates/migration.rb
rolify-3.3.0.rc1 lib/generators/rolify/role/templates/migration.rb
rolify-3.2.0 lib/generators/rolify/role/templates/migration.rb
rolify-3.2.0.rc2 lib/generators/rolify/role/templates/migration.rb
rolify-3.1.0 lib/generators/rolify/role/templates/migration.rb
rolify-3.0.0 lib/generators/rolify/role/templates/migration.rb
rolify-2.2.2 lib/generators/rolify/role/templates/migration.rb
rolify-2.2.1 lib/generators/rolify/role/templates/migration.rb
rolify-2.2.0 lib/generators/rolify/role/templates/migration.rb
rolify-2.1.0 lib/generators/rolify/role/templates/migration.rb
rolify-2.0.0 lib/generators/rolify/role/templates/migration.rb
rolify-1.2.0 lib/generators/rolify/role/templates/migration.rb
rolify-1.1.0 lib/generators/rolify/role/templates/migration.rb
rolify-1.0.0 lib/generators/rolify/role/templates/migration.rb
rolify-0.7.0 lib/generators/rolify/role/templates/migration.rb
rolify-0.6.0 lib/generators/rolify/role/templates/migration.rb