Class: CreateGroupsAndGroupsUsers

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

Instance Method Summary collapse

Instance Method Details

#downObject


15
16
17
18
# File 'lib/generators/templates/groups_migration.rb', line 15

def down
  drop_table :groups
  drop_table :groups_users
end

#upObject


2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/generators/templates/groups_migration.rb', line 2

def up
  create_table :groups do |t|
    t.string :name
  end

  create_table :groups_users do |t|
    t.references :group
    t.references :user
  end

  add_index :groups_users, [:group_id, :user_id], unique: true
end