evilmartians / evil-seed

A Gem for creating partial anonymized dumps of your database using your app model relations.
MIT License
447 stars 19 forks source link

Excluding tables #9

Closed adaam2 closed 5 years ago

adaam2 commented 5 years ago

First of all, thanks for your wonderful work. This gem is 100000x better than our custom dump script.

Your docs mention the exclude method for excluding associations of a model, but there are a few tables where I would like to exclude all data from the dump. I tried to add a constraint of created_at > Time.now to exclude in slightly naive way, but of course by the time the dump of the tables occurred Time.now had passed.

Apologies if I have accidentally skimmed over how to do this in your documentation

Envek commented 5 years ago

Why did you close this issue? Did you find a solution?


  1. If tables that you want to exclude aren't connected to your other models they won't be dumped
  2. Otherwise they will be dumped while traversing associations from one of the specified roots unless you will forbid them with exclude. E.g. if you have “users has many posts has many likes belongs to likers” and you want recent posts with authors and likes but without liked users you can do something like this:

    config.root("Post", 'created_at > ?', 1.week.ago) do |root|
      root.exclude('likes.liker')
    end