Module: Msf::DBManager::Migration
- Included in:
- Msf::DBManager
- Defined in:
- lib/msf/core/db_manager/migration.rb
Instance Attribute Summary collapse
-
#migrated ⇒ Boolean?
Flag to indicate database migration has completed.
Instance Method Summary collapse
-
#add_rails_engine_migration_paths ⇒ Object
Loads Metasploit Data Models and adds gathers migration paths.
-
#migrate(config = nil, verbose = false) ⇒ Array<ActiveRecord::MigrationProxy] List of migrations that ran.
Migrate database to latest schema version.
-
#needs_migration? ⇒ Boolean
Determine if the currently established database connection needs migration.
Instance Attribute Details
#migrated ⇒ Boolean?
Flag to indicate database migration has completed
64 65 66 |
# File 'lib/msf/core/db_manager/migration.rb', line 64 def migrated @migrated end |
Instance Method Details
#add_rails_engine_migration_paths ⇒ Object
Loads Metasploit Data Models and adds gathers migration paths.
6 7 8 9 10 11 12 13 14 |
# File 'lib/msf/core/db_manager/migration.rb', line 6 def add_rails_engine_migration_paths unless defined? ActiveRecord fail "Bundle installed '--without #{Bundler.settings.without.join(' ')}'. To clear the without option do " \ "`bundle install --without ''` (the --without flag with an empty string) or `rm -rf .bundle` to remove " \ "the .bundle/config manually and then `bundle install`" end gather_engine_migration_paths end |
#migrate(config = nil, verbose = false) ⇒ Array<ActiveRecord::MigrationProxy] List of migrations that ran.
Migrate database to latest schema version.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/msf/core/db_manager/migration.rb', line 24 def migrate(config=nil, verbose=false) ran = [] ActiveRecord::Migration.verbose = verbose ActiveRecord::Base.connection_pool.with_connection do begin with_migration_context do |context| if context.needs_migration? ran = context.migrate end end # ActiveRecord::Migrator#migrate rescues all errors and re-raises them as StandardError rescue StandardError => error self.error = error elog('DB.migrate threw an exception', error: error) end end # Since the connections that existed before the migrations ran could # have outdated column information, reset column information for all # ApplicationRecord descendents to prevent missing method errors for # column methods for columns created in migrations after the column # information was cached. reset_column_information ran end |
#needs_migration? ⇒ Boolean
Determine if the currently established database connection needs migration
55 56 57 58 59 |
# File 'lib/msf/core/db_manager/migration.rb', line 55 def needs_migration? with_migration_context do |context| return context.needs_migration? end end |