Sha256: 0a5732c948c49eaf3135b4552e607ba84b091c125c99ab247971e9bf6236ae9e
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
namespace :foreman_docker do desc 'Clean default data created by this plugin, this will permanently delete the data!' task :cleanup => :environment do puts 'Cleaning data...' User.as_anonymous_admin do puts '... deleting records from taxable_taxonomies' TaxableTaxonomy.where(:taxable_type => [ 'Container', 'DockerRegistry', 'Preliminary', 'ForemanDocker::Docker' ]).delete_all puts '... deleting filters' Filter.joins(:permissions).where('permissions.resource_type' => Foreman::Plugin.find(:foreman_docker).registered_permissions.map { |p, attrs| attrs[:resource_type] }.uniq!).destroy_all puts '... deleting permissions' Permission.where(:name => Foreman::Plugin.find(:foreman_docker).registered_permissions.map(&:first)).destroy_all puts '... deleting docker compute resources' ForemanDocker::Docker.destroy_all puts 'data from all tables deleted' end tables = [ :containers, :docker_registries, :docker_container_wizard_states, :docker_container_wizard_states_preliminaries, :docker_container_wizard_states_images, :docker_container_wizard_states_configurations, :docker_container_wizard_states_environments, :docker_parameters ] tables.each do |table| puts "... dropping table #{table}" ActiveRecord::Migration.drop_table table end puts 'Clean up finished, you can now remove the plugin from your system' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_docker-5.0.0 | lib/tasks/cleanup.rake |
foreman_docker-4.1.1 | lib/tasks/cleanup.rake |