diff --git a/README.md b/README.md index a62dfbe..40829c3 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,14 @@ Account.unrelease_to_all(:email_marketing, :new_email_flow) Account.released_features_to_all ``` +## Clean up action + +By default when a key is removed from `rollout.yml` file, its data still in the storage. + +To clean it up, execute or schedule the rake: + + $ bundle exec rake feature_flagger:cleanup_removed_rollouts + ## Contributing Bug reports and pull requests are welcome! diff --git a/lib/feature_flagger.rb b/lib/feature_flagger.rb index 60aa6f6..7894533 100644 --- a/lib/feature_flagger.rb +++ b/lib/feature_flagger.rb @@ -7,6 +7,7 @@ require 'feature_flagger/feature' require 'feature_flagger/configuration' require 'feature_flagger/manager' +require 'feature_flagger/railtie' module FeatureFlagger class << self diff --git a/lib/feature_flagger/railtie.rb b/lib/feature_flagger/railtie.rb new file mode 100644 index 0000000..4e41180 --- /dev/null +++ b/lib/feature_flagger/railtie.rb @@ -0,0 +1,9 @@ +if defined?(Rails) + module FeatureFlagger + class Railtie < Rails::Railtie + rake_tasks do + load 'tasks/cleanup.rake' + end + end + end +end \ No newline at end of file diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake new file mode 100644 index 0000000..2136d30 --- /dev/null +++ b/lib/tasks/cleanup.rake @@ -0,0 +1,10 @@ +namespace :feature_flagger do + desc "cleaning up keys from storage that are no longer in the rollout.yml file" + task :cleanup_removed_rollouts => :environment do + keys = FeatureFlagger::Manager.detached_feature_keys + puts "Found keys to remove: #{keys}" + keys.each do |key| + FeatureFlagger::Manager.cleanup_detached key + end + end +end \ No newline at end of file