Git Product home page Git Product logo

evil-seed's People

Contributors

atipugin avatar cmer avatar envek avatar guillaumewrobel avatar nhocki avatar palkan avatar sfate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

evil-seed's Issues

Excluding tables

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

Recursive execution?

    def dump_belongs_to_associations!
      belongs_to_reflections.map do |reflection|
        next if to_load_map[reflection.name].empty?
        RelationDumper.new(
          build_relation(reflection),
          root_dumper,
          "#{association_path}.#{reflection.name}",
          search_key:       reflection.association_primary_key,
          identifiers:      to_load_map[reflection.name],
          limitable:        false,
        ).call
      end
    end

From RelationDumper - to me it seems like this is recursive, which might cause some resource issues in a larger DB with a lot of relationships.

Rails 4.2.x and jruby compatibility

Hello. In our Rails 4.2.11 app on jruby 9.2.5.0, I'm seeing the following error. I put some print statements into the refinements configuration code that back ports the in_batches method to ActiveRecord::Relation in Rails 4.2, and they print out as expected. So I'm not sure why this isn't available at runtime. This error happens on a simple usage based on the documentation, trying to navigate the first configured model's associations.

NoMethodError: undefined method `in_batches' for #<User::ActiveRecord_Relation:0x39352f6b>

Do you know if refinements work in jruby?

It appears that may not be the case, which was surprising. (still investigating) jruby/jruby#4330

Ignoring columns or avoiding errors

Hi! After starting to use this gem, I found that adding translations to models breaks the queries done by EvilSeed.
For example, by using I18n and Globalize:

class Person < ActiveRecord
  translates :name
  globalize_accessors locales: [:en, :pt, :es], attributes: [:name]
end

And when dumping the database, it aborts and shows the following error: PG::UndefinedColumn: ERROR: column "name" does not exist

Is there any way to ignore columns or avoid these translations?
Thanks!

Errno::EMFILE: Too many open files @ rb_sysopen

Had this error trying to run EvilSeed.dump('...'):
Errno::EMFILE: Too many open files @ rb_sysopen - /tmp/evil_seed_prompts_users_20230929-89080-1h4sbb.sql
Resolved it by running ulimit -n 10240 before doing the dump (limit was 1024). This cannot be run inside the script itself, as it won't change the limit of the ruby process itself.
Just adding this in case it may help someone. And maybe there's a way to improve the dumping logic to not open so many files?

Thanks a lot for the great gem!

Foreign key nullification

Hey! Sorry to bother again, but this time I found an issue that I don't know if it is really a bug or just something about my schema or configuration.

For example, I have 3 models, Person, Car, PersonCarBorrow, and the PersonCarBorrow has defined:

belongs_to :person
belongs_to :car

And when dumping this schema, with root on Person, the PersonCarBorrow will have the Person foreign key person_id NULL, and the Car foreign key with the correct value.

My gems versions:

activerecord (= 5.2.6)
evil-seed (0.2.0)

After a little search, I think the issue is related with this line relation_dumper#149, as the foreign_key is nullified because of the condition on excluded = ... || reflection.name == inverse_reflection.
A fork of this gem already made a change related to this shippio/evil-seed-41025192b46649cf43af91d7fd7a80358a9e7379.

Thank you for your help.

Support for Foreign Key attribute on belongs_to

My issue is i have a belongs_to relationship with a foreign_key defined but it's looking for the rails foreign key instead of my belongs_to foreign_key attribute i am wondering if this has happened or if the library is still supported

Model with ActiveStorage attachment can't be anonymized

When I try to anonymize a model with an active storage attachment. E.g. User with a profile picture

# lib/extensions/evil_seed.rb

require "evil_seed"

EvilSeed.configure do |config|
  config.root("User", id: 13055) do |root|
    root.exclude(/.*/) # exclude all associations
  end

  config.anonymize("User") do
    name { Faker::Name.name }
  end
end

I get a method_missing for has_one_attached on this model.

/Users/billabel/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-6.1.7.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for User:Class (NoMethodError)

Is there a fix or workaround? Is this a ruby 3.2 issue?

Invalid SQL order by clause from root model configuration

With no Evil Seed configuration on the root model, just the model name, it seems like the SQL being generated includes an ORDER BY with the table name and then no field name, which is invalid, this bit: ORDER BY "users"."" ASC.

EvilSeed.configure do |config|
  config.root('User') do |root|
  end
end
EvilSeed.dump(File.join(__dir__, "dump.sql").to_s)

I'm getting this kind of error:

ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: zero-length delimited identifier at or near """"
  Position: 50: SELECT  "users".* FROM "users"  ORDER BY "users"."" ASC LIMIT 1000

Rails 4.2.11, Jruby 9.2.5.0, I have hacked the in_batches to be find_in_batches locally, which I don't think is related. Do you know where this order by clause is coming in? Do you have a suggestion on how to get it removed? Without the order by clause, the rest of the statement is valid.

Ignore generated columns

Is there an easy way to ignore specific columns, specifically generated columns?

Error:
BasicsTest#test_basic_runthrough:
ActiveRecord::StatementInvalid: PG::GeneratedAlways: ERROR:  cannot insert a non-DEFAULT value into column "full_name"
DETAIL:  Column "full_name" is a generated column.

    test/system/basics_test.rb:26:in `block (2 levels) in init_seeds'
    test/system/basics_test.rb:25:in `each'
    test/system/basics_test.rb:25:in `block in init_seeds'
    test/system/basics_test.rb:19:in `init_seeds'
    test/system/basics_test.rb:37:in `block in <class:BasicsTest>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.