Class: GroupifyMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/groupify/active_record/migration/templates/migration.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/groupify/active_record/migration/templates/migration.rb', line 2

def change
  create_table :groups do |t|
    t.string     :type
  end

  create_table :group_memberships do |t|
    t.references :member, polymorphic: true, index: true, null: false
    t.references :group, polymorphic: true, index: true

    # The named group to which a member belongs (if using)
    t.string     :group_name, index: true

    # The membership type the member belongs with
    t.string     :membership_type

    t.timestamps
  end
end