Skip to content

Commit

Permalink
Merge branch 'md/usage-report' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
tvcam committed Aug 23, 2023
2 parents b17b771 + 262337a commit ac971bd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/tasks/clean_unused_schema.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
desc 'Clean unused schema'
task :clean_unused_schema => :environment do
Organization.without_shared.only_deleted.each do |org|
puts "================ Dropping schema #{org.short_name} ================"

begin
Apartment::Tenant.drop(org.short_name)
rescue Apartment::TenantNotFound => e
puts "================ Schema #{org.short_name} not found ================"
end

UsageReport.where(organization_id: org.id).destroy_all
org.destroy_fully!
end
end

0 comments on commit ac971bd

Please sign in to comment.