No release in over 3 years
Low commit activity in last 3 years
Delete/destroy associated ActiveRecord records in the background with ease.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.11.3
>= 3.0
>= 0
~> 3.0

Runtime

 Project Readme

DeleteYouLater

Deletes/destroys associated records in the background, because destroying a billion records in the foreground just will not work.

Why

Because you probably have destroy callbacks and those are the devil. 😈🔱

Installation

Add this line to your application's Gemfile:

gem 'delete_you_later'

And then execute:

$ bundle

Usage

class Post < ApplicationRecord
  has_many :posts 
  has_many :likes
  
  destroy_dependents_later :posts
  delete_dependents_later :likes
end

Configuration

Drop into an initializer:

DeleteYouLater.configure do |config|
  config.scope = :published # default is not scoped
  config.batch_size = 100_000 # default is 100
end

You can change these at runtime:

class Post < ApplicationRecord
  has_many :comments
  
  destroy_dependents_later :comments, batch_size: 10, scope: :unapproved 
end

Contributing

This isn't one-size-fits-all but one-size-fits-joshmn's-clients. It might help you too, if not at least give you inspiration for modeling this in your application. I've used this for billions of records with success. Don't ask about my failures.

Bug reports and pull requests are kindly welcomed on GitHub at https://github.com/joshmn/delete_you_later

License

The gem is available as open source under the terms of the MIT License.