Files
metasploit-gs/data/sql/migrate/002_add_workspaces.rb
T
Mike Smith f9ffc8b8bc Add db_workspace command & other db refactoring.
* Added "workspaces" table and associated ActiveRecord class.
 * Moved ActiveRecord models from db_objects.rb into separate files.
 * Do the DB migration check every time you connect (was previously done
   during db_create).
 * Use :dependent => :destroy associations so that we don't have to
   manually delete the dependent objects.

git-svn-id: file:///home/svn/framework3/trunk@7861 4d416f70-5f16-0410-b530-b9f4589650da
2009-12-14 22:52:34 +00:00

29 lines
533 B
Ruby

class AddWorkspaces < ActiveRecord::Migration
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
w = Msf::DBManager::Workspace.default
Msf::DBManager::Host.update_all ["workspace_id = ?", w.id]
end
def self.down
drop_table :workspaces
change_table :hosts do |t|
t.remove :workspace_id
end
add_index :hosts, :address, :unique => true
end
end