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
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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
|
||||
Reference in New Issue
Block a user