Class: BobbyCreateTables

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

Class Method Summary collapse

Class Method Details

.downObject



41
42
43
44
45
46
47
48
# File 'lib/generators/bobby/install/templates/migration.rb', line 41

def self.down
  drop_table :group_users_users
  drop_table :group_users
  drop_table :permissions_roles
  drop_table :authorisations
  drop_table :roles
  drop_table :permissions
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/generators/bobby/install/templates/migration.rb', line 2

def self.up
  create_table :permissions do |t|
    t.string :name
    t.string :actions_allowed
    t.text   :on_tables

    t.timestamps
  end
  create_table :roles do |t|
    t.string :name

    t.timestamps
  end
  create_table :authorisations do |t|
    t.references :authorisable, :polymorphic => true 
    t.integer :role_id

    t.timestamps
  end
  create_table :permissions_roles, :id => false do |t| 
    t.integer :permission_id
    t.integer :role_id

    t.timestamps
  end
  create_table :group_users do |t|
    t.string :name

    t.timestamps
  end
  create_table :group_users_users, :id => false do |t| 
    t.integer :group_user_id
    t.integer :user_id

    t.timestamps
  end

end