Skip to content

Commit

Permalink
Allow use of rake db tasks
Browse files Browse the repository at this point in the history
[#46224565]

The following rake tasks are added and work similar to how they work in
rails apps:
* db:create
* db:drop
* db:migrate
* db:migrate:status
* db:rollback
* db:schema:dump
* db:schema:load
* db:seed (but no db seeds defined at this time)
* db:setup
* db:version

The hidden task db:test:prepare is also available, which means `rake
spec` can depend on it so that the test database is dropped and
recreated from the development database when running specs (Although
there are yet to be database tests, this branch is in preparation for
that work that will be split between multiple developers.)
  • Loading branch information
limhoff-r7 committed Mar 14, 2013
1 parent d8f46e3 commit 2604fad
Show file tree
Hide file tree
Showing 7 changed files with 800 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
.yardoc
# Mac OS X files
.DS_Store
# database config for testing
config/database.yml
# simplecov coverage data
coverage
data/meterpreter/ext_server_pivot.dll
Expand Down
14 changes: 13 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ require 'bundler/setup'

require 'metasploit_data_models'

#
# load rake files like a rails engine
#

pathname = Pathname.new(__FILE__)
root = pathname.parent
rakefile_glob = root.join('lib', 'tasks', '**', '*.rake').to_path

Dir.glob(rakefile_glob) do |rakefile|
load rakefile
end

print_without = false

begin
Expand All @@ -12,7 +24,7 @@ rescue LoadError

print_without = true
else
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare')

task :default => :spec
end
Expand Down
21 changes: 21 additions & 0 deletions config/database.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Please only use postgresql bound to a TCP port.
development: &pgsql
adapter: postgresql
database: metasploit_framework_development
username: metasploit_framework_development
password: __________________________________
host: localhost
port: 5432
pool: 5
timeout: 5

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
#
# Note also, sqlite3 is totally unsupported by Metasploit now.
test:
<<: *pgsql
database: metasploit_framework_test
username: metasploit_framework_test
password: ___________________________
Loading

0 comments on commit 2604fad

Please sign in to comment.