Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't run migrate templates to mappings if the mappings table doesn't exist #1272

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions config/initializers/z_11_plugin_templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +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
Dradis::Plugins::with_feature(:upload).each do |integration|
integration.copy_samples(to: template_dir)
integration.migrate_templates_to_mappings(from: template_dir)
integration.migrate_templates_to_mappings(from: template_dir) if !Rails.env.test?
end

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