Skip to content

Commit

Permalink
move mappings table existence check to existing if block
Browse files Browse the repository at this point in the history
  • Loading branch information
caitmich committed Jun 20, 2024
1 parent 5a18f7c commit d539c2d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions config/initializers/z_11_plugin_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
# Unless the DB is already migrated, do nothing

Rails.application.reloader.to_prepare do
if (ActiveRecord::Base.connection rescue false) && Configuration.table_exists? && Configuration.paths_templates.exist?
if (ActiveRecord::Base.connection rescue false) &&
Configuration.table_exists? &&
Configuration.paths_templates.exist? &&
Mapping.table_exists?
# ---------------------------------------------------------------- 3.1 Upload
template_dir = Configuration.paths_templates_plugins
# mappings table may not exist when migrating from an old OVA to a new one so we need this guard
if Mapping.table_exists?
Dradis::Plugins::with_feature(:upload).each do |integration|
integration.copy_samples(to: template_dir)
integration.migrate_templates_to_mappings(from: template_dir) if !Rails.env.test?
end
Dradis::Plugins::with_feature(:upload).each do |integration|
integration.copy_samples(to: template_dir)
integration.migrate_templates_to_mappings(from: template_dir) if !Rails.env.test?
end

# ---------------------------------------------------------------- 3.2 Export
Expand Down

0 comments on commit d539c2d

Please sign in to comment.