Class: AddWorkspaces

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
db/migrate/002_add_workspaces.rb

Class Method Summary collapse

Class Method Details

.downObject



26
27
28
29
30
31
32
33
34
# File 'db/migrate/002_add_workspaces.rb', line 26

def self.down
  drop_table :workspaces

  change_table :hosts do |t|
    t.remove   :workspace_id
  end

  add_index :hosts, :address, :unique => true
end

.upObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'db/migrate/002_add_workspaces.rb', line 3

def self.up
  create_table :workspaces do |t|
    t.string    :name
    t.timestamps
  end

  change_table :hosts do |t|
    t.integer   :workspace_id, :required => true
  end

  remove_index :hosts, :column => :address

  #
  # This was broken after 018_add_workspace_user_info was introduced
  # because of the new boundary column.  For some reason, the
  # find_or_create_by_name that .default eventually calls here tries to
  # create a record with the boundary field that doesn't exist yet.  
  # See #1724
  #
  #w = Msf::DBManager::Workspace.default
  #Msf::DBManager::Host.update_all ["workspace_id = ?", w.id]
end