Giter Club home page Giter Club logo

seed_dump's People

Contributors

alexesdev avatar cschramm avatar ebakan avatar guilhermesimoes avatar h6y3 avatar jann avatar jhirbour avatar kofronpi avatar ktaragorn avatar lambda2 avatar limratana avatar luka-n avatar mibamur avatar nobrick avatar ognevsky avatar olegpasko avatar poctek avatar rhalff avatar ricciflowing avatar rroblak avatar seuros avatar tapocol avatar uberbrodt 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

seed_dump's Issues

Dump id in addition to other attributes

I just heard about this gem, and even though I've been using it for less than ten minutes, it looks really useful.

However, I can't quite figure out how to dump the (hidden) "id" attribute that Rails adds to models. I suppose that isn't a problem for most people, since Rails enables "auto-increment" on the ids by default, but for me it's very important to have the exact same id when importing/exporting the database from seeds.rb.

Is such a thing possible with your gem?

Not getting ids

I stuck one thing I want to get ids for all models as well how can I do this for example currently if I run
=> rake db:seed:dump
I just get code like this

=> Product.create(title: "title", description: "text")
but I want this

=> Product.create(id: 1, title: "title", description: "text")
how can i do that?

One more option: separated actions for one model

In some cases (happened with me) something like:
Modelname.create(name: 'name');
Modelname.create(name: 'second_name');
will be more usefull, instead of:
Modelname.create([ { name: "name" }, { name: "second_name" }])

For example, we can use seed_dump for DB transfer and it may contain a lot of data. When we will seed it, one huge create use a lot of memory (in VPS/VDS) and proces may be killed coz not enought memory.

Could this be useful? If yes โ€” I can try to do this feature in this gem :)

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Is Active Record Associations supported?

Hi!
If I want to get some model, and all records, belonging to it, how can I do this?
For example, I have User model, and UserAction model (User has_many :user_actions and UserAction belongs_to :user). I want to get 100 UserAction random copies, and all Users belonging to them, but no other users.
Thank you.

PG_SCHEMA option removed

I was trying to dump a PostgreSQL schema to seed.rb, but it wasn't dumping the specified schema. Digging deeper, I noticed that the PG_SCHEMA option was removed shortly after v1.0.0. What's the reasoning behind its removal?

What's the best practice or workaround on this? (I have a template schema that I modify via my app, and every now and then, I'd like to capture its state using a seed file.)

Thanks!

comparison of Class with Class failed

Running Rails 3 on ruby 1.9.2 and seed_dump from github master branch.

rake db:seed:dump --trace
** Invoke db:seed:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:seed:dump
rake aborted!
comparison of Class with Class failed
/home/slava/.rvm/gems/ruby-1.9.2-p180/bundler/gems/seed_dump-b96bbe62e786/lib/seed_dump/perform.rb:68:in sort' /home/slava/.rvm/gems/ruby-1.9.2-p180/bundler/gems/seed_dump-b96bbe62e786/lib/seed_dump/perform.rb:68:indumpModels'
/home/slava/.rvm/gems/ruby-1.9.2-p180/bundler/gems/seed_dump-b96bbe62e786/lib/seed_dump/perform.rb:88:in run' /home/slava/.rvm/gems/ruby-1.9.2-p180/bundler/gems/seed_dump-b96bbe62e786/lib/tasks/seed_dump.rake:6:inblock (3 levels) in <top (required)>'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in call' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:inblock in execute'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in each' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:inexecute'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:158:in block in invoke_with_call_chain' /home/slava/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in invoke_with_call_chain' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:144:ininvoke'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:112:in invoke_task' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:inblock (2 levels) in top_level'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in each' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:inblock in top_level'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in standard_exception_handling' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:84:intop_level'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:62:in block in run' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:instandard_exception_handling'
/home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in run' /home/slava/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in<top (required)>'
/home/slava/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in load' /home/slava/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in

'
Tasks: TOP => db:seed:dump

Documentation issue

In the README it says:

Dump only data from the users table and dump a maximum of 1 record:
$ rake db:seed:dump MODELS=User,Product LIMIT=1

Shouldn't it be

$ rake db:seed:dump MODELS=User LIMIT=1

Syntax error for ruby 1.8.7 and limit not working

So at first I stumbled on the syntax, issue -> It was farely easy to fix in environment.rb:23-27 and dump_methods.rb:33, also dump_methods.rb:26 |key| --> |key,value| because it complained about the missing parameter...
But then I stumbled on the fact that the limit feature doesnt seem to be working, so I added the limit as the count for the batch_calculator, thus tricking the system to think, that the limit is also the maximum.

enumeration.rb:58 ENV["LIMIT"] ||= records.count

enumeration.rb:59 count = [records.count,options[:limit]].min

๐Ÿ˜€

Adding a "Where" clause

We have an OLD database that has tons of old historical records in it. (archiving says what??) .

I've run into issues where I only want to create seed data for our local dev machines with "active" data from production .

Do you think it'd be a good idea to add the ability to tag on a where clause to the dump?

"Where is_active=TRUE" or ".where(:is_active => true)" something like that...

This might also help in making seed data for specific situations or test cases (or should I be using fixtures more...)

Dumping data from PostgreSQL using inet data type

Using Rails 4.1.2 and Ruby 2.1.2 under OSX.

We have a table with usersessions that uses the 'inet' type in PostgreSQL. This will return the following data when dumping data:

Usersession.create!([
{user_id: "176227ba-cf77-43c6-95b6-dedd27c65b81", ip: #<IPAddr: IPv4:1.2.3.4/255.255.255.255>, user_agent: "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405", proxy: nil},
{user_id: "f02a123e-bb12-4d9a-b741-1f13a6ca75d5", ip: #<IPAddr: IPv4:1.2.3.4/255.255.255.255>, user_agent: "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405", proxy: nil}
])

The IP is invalid - should probably be dumped as ip.to_s which will give 1.2.3.4 as expected.

exclude option throws error in console

I'm unable to get the exclude option to work in console. Am I misunderstanding how to pass it in?

irb(main):016:0> puts SeedDump.dump(Model, exclude: '')
TypeError: no implicit conversion of Symbol into String

Error when dumping: "error: private method `desc' called for main:Object"

I've recently started getting and error when trying to dump a single model via the rake command. I've tried several different models and get the same error.

I'm using master from this repo so it may be a "bleeding age" bug...

== Gem file ==

gem 'rails', '~> 4.0.2'
gem 'seed_dump', git: 'https://github.com/rroblak/seed_dump'
rake db:seed:dump MODEL=SiteTrackingUrl FILE=db/seeds/site_tracking_url.seeds.rb
(path to my app)
error: private method `desc' called for main:Object

When I try it from the Rails Console it works fine, I get the expected output that would normally be in the output file.

SeedDump.dump(SiteTrackingUrl)

Googling the error brings this up: davetron5000/gli#153

So I'm guessing it might be an issue like that one? Because it only DOESN'T work from Rake.

Let me know if you need additional information to troubleshoot.

Validation

It would be nice if it could skip validation on the models, a use case for this would be use with devise for example.

Relationships are not retained

I ran rake db:seed:dump MODEL="Category, Products". I was expecting it to keep the relationships but it didn't. It jumbles the order of Category, so that when the Product.create refers to the category_id, it will have pointed to the wrong Category.

from rails console in the ENV where I ran the command:

> Category.find_by(correct_category:true).id == 1
=> true
> Product.count
=> 1
> Product.first.category_id == 1
=> true

But the command generates the following seeds.rb:

Category.create([
  { correct_category:false },
  { correct_category:false },
  { correct_category:true }
])
Product.create([
  { category_id: 1 }
])

Doesn't handle foreign keys.

Needs to delay emitting any record that has a foreign key to another one which hasn't yet been dumped. In the case of circular associations this means it may need to insert multiple separate batches of the same record type.

Compatibility with Rails 5.0

With the release of Rails 5.0.0.beta1 just days ago, many users (myself included) are seeking to upgrade their current Rails 4.2 apps to ensure forward-compatibility with this new version of Rails and to make use of its new features and capabilities.

Currently, the seed_dump.gemspec includes the lines:

s.add_runtime_dependency(%q<activesupport>, ["~> 4"])
s.add_runtime_dependency(%q<activerecord>, ["~> 4"])

which prevents usage of this gem (or even experimentation with it) in this new version of Rails.

I would like to request that seed_dump be made compatible with Rails 5.0.

support for mongoid?

try to generate seed from mongoid, I got

spondbob@bikinibottom ~/project $ rake db:seed:dump
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
rake aborted!
uninitialized constant SeedDump::Environment::ActiveRecord
/home/spondbob/.rvm/gems/ruby-2.1.0@sewakamar/gems/seed_dump-3.1.0/lib/seed_dump/environment.rb:10:in `dump_using_environment'
/home/spondbob/.rvm/gems/ruby-2.1.0@sewakamar/gems/seed_dump-3.1.0/lib/tasks/seed_dump.rake:6:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:seed:dump
(See full trace by running task with --trace)

encoding in seed file

Hello,

Sometimes table has non english chars so when dumping the rows to seed.rb file it includes these chars but when trying to rake db:seed then exception fired because of these chars.

To fix this issue just append # encoding: UTF-8 in the top of generated file.

Is it possible to make this automatically?

Thank you

Breaks validations for associations

I've got a database with Games, Ratings, and Users, and naturally the Ratings validate that both their User and their Game exist. By default, the seed dump breaks this by putting everything into the file in alphabetical order. Could you add an option for specifying order?

APPEND=false broken when first model has no records

Right now, the way appending is implemented is that the default of APPEND is set to false, and then after the first dump, APPEND is set to true. My first model being dumped has no records in it, so the first dump is skipped entirely, including deleting the seeds file when APPEND is set to false, so the seeds file never gets deleted. This results in APPEND=false effectively not working at all.

Rails 3 version 0.5.3 undefined method `dump' for SeedDump:Module

Trying to use the console as in the README:

1.9.3-p194 :013 > puts SeedDump.dump(User)
NoMethodError: undefined method `dump' for SeedDump:Module
    from (irb):13
    from /home/ace/.rvm/gems/ruby-1.9.3-p194@global/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
    from /home/ace/.rvm/gems/ruby-1.9.3-p194@global/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
    from /home/ace/.rvm/gems/ruby-1.9.3-p194@global/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
1.9.3-p194 :014 > 

id is not dumped, created_at and updated_at are

In the README it says:

exclude: Attributes to be excluded from the dump. Default: id, created_at, updated_at.

But the result of rake db:seed:dump is:

Birthcountry.create([
  { :name => "St. Eustatiuss", :created_at => "2013-12-21 20:53:43", :updated_at => "2014-01-10 13:09:27" },
  { :name => "iutuyiyui", :created_at => "2013-12-29 13:26:37", :updated_at => "2013-12-29 13:26:37" }
], :without_protection => true )

This is version 0.5.3 with Rails 3.

Transfer

After the transfer I directly got a 404 for the project,
do you still have the links for rubygems and your email (not sure if I need that though)

request add support for chunking 1 table into multiple seed files

I have some tables with 100k to 1M rows that I would like to turn into seed files. Files over about 100k rows can get too big to work with, depending on the number of attributes. I would like to be able to pass a parameter such as file_chunk_size: 100,000 that would cause your program to create a new seed file every 100k rows.

Just a request. Great tool, thank you!

Support for Rails Engines?

I'm using Rails 4 + Spree and trying to seed_dump some of it's data.

Spree installs as a Rails Engine and has tables in the DB spree_some_table_name

I've tried a few variations and none seem to dump the data out.

I've tried use Spree::OptionType as the model name (doesn't generate an error)

I've tried using SpreeOptionType as the model name (doesn't generate an error)

I've also tried pointing the MODEL_DIR to the spree gems path.

rake db:seed:dump WITH_ID=true RAILS4=true WITHOUT_PROTECTION=false MODEL_DIR=/some/really/long/path/to/the/spree/gem/app/models/ MODELS=OptionType FILE=db/seeds/spree_option_type.seeds.rb

Does seed_dump support rails engines? Can you add some documentation on how to make it work?

Option for ONLY

In addition to excluding attributes, it would be nice to have an option to opt-in and get only the whitelisted attributes

Could be something like this:

attribute_strings << dump_attribute_new(attribute, value, options) if options[:include].include?(attribute.to_sym)

Obviously EXCLUDE could be ignored in this case

Undefined method []

undefined method []' for #<ActiveModel::MassAssignmentSecurity::WhiteList: {}> /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:90:inblock (2 levels) in dumpModel'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:89:in each' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:89:inblock in dumpModel'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:87:in each' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:87:ineach_with_index'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:87:in dumpModel' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:118:inblock in dumpModels'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:107:in each' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:107:indumpModels'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:162:in run' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/seed_dump-0.4.1/lib/tasks/seed_dump.rake:6:inblock (3 levels) in <top (required)>'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in call' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:inblock in execute'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in each' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:inexecute'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:595:in block in invoke_with_call_chain' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:588:in invoke_with_call_chain' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:581:ininvoke'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2041:in invoke_task' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:inblock (2 levels) in top_level'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in each' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:inblock in top_level'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2058:in standard_exception_handling' /Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2013:intop_level'
/Users/blanchma/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:1992:in run' /Users/blanchma/.rbenv/versions/1.9.2-p290/bin/rake:31:in

'

Undefined method 'expr' for 1000:Fixnum

I'm getting an Undefined method 'expr' for Fixnum error when I run the following in the console:
SeedDump.dump(IngestHistory, file: '../project/tmp/seeds/ingest_histories.rb', limit: 20)

I get the same error when I run the equivalent command from a terminal. I hope to find the time to contribute and look into this error, but right this second I figured I'd get the issue out there.

Attaching the relevant stack trace below:
screen shot 2015-10-12 at 2 58 34 pm

superclass must be a Class (Module given)

Protection is disabled.
rake aborted!
superclass must be a Class (Module given)
app/models/Invite/completion_agreement.rb:1:in `<top (required)>'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:251:in `require'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:251:in `block in require'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:251:in `require'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/seed_dump-0.5.3/lib/seed_dump/perform.rb:58:in `block in loadModels'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/seed_dump-0.5.3/lib/seed_dump/perform.rb:41:in `each'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/seed_dump-0.5.3/lib/seed_dump/perform.rb:41:in `loadModels'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/seed_dump-0.5.3/lib/seed_dump/perform.rb:179:in `run'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/seed_dump-0.5.3/lib/tasks/seed_dump.rake:6:in `block (3 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/user/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:seed:dump
(See full trace by running task with --trace)

class Invite::CompletionAgreement < Invite
  def redirection_url
    business_plan_completion_agreement_path(business_plan)
  end
end

Trouble with bigdecimal

I love this plugin, but I have a problem when the model contains bigdecimal objects. I get stuff like this:
{test: "arm_curl", gender: "male", min_age: 65, max_age: 69, scores: [#<BigDecimal:7fc7c9662108,'0.27E2',9(18)>, #<BigDecimal:7fc7c9662090,'0.25E2',9(18)>]},

I'm using postgres, and the column types are t_integer and t_decimal.

When I run the seed file, it bombs with:
SyntaxError: /vagrant/db/seeds.rb:89: syntax error, unexpected ')', expecting '}'

Any ideas?

Duplicate PKs when dumping from rails console

When I use the rails console to dump a model (from MySQL), I get duplicate PKs from my table. When I dump it from the rake task it works fine (IE doesn't create dup keys). It looks like something to do with the offset/chunking code. I'm using "EXCLUDE=" because I need the PKs.

The model is for a legacy table and doesn't comply to rails naming conventions :-(

My Model:

class ItemPricePoint < ActiveRecord::Base
    self.table_name = 'itemPricePoint'
    belongs_to :inventoryitem, :class_name => 'InventoryItem', :foreign_key => :inventoryItemId
end

Works (produces a seed file exactly the same as the database):

rake db:seed:dump MODELS=ItemPricePoint EXCLUDE= FILE=db/seeds/item_pricepoint.seeds.rb

Doesn't work (makes dup PKs):

>> SeedDump.dump(ItemPricePoint, file: 'db/seeds/item_pricepoint.seeds.rb', append: false, exclude: {})
   (1.2ms)  SELECT COUNT(*) FROM `itemPricePoint`
   (1.3ms)  SELECT COUNT(*) FROM `itemPricePoint`
  ItemPricePoint Load (3.6ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 1000 OFFSET 0
  ItemPricePoint Load (3.7ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 1000 OFFSET 1000
  ItemPricePoint Load (3.9ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 1000 OFFSET 2000
  ItemPricePoint Load (4.0ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 1000 OFFSET 3000
  ItemPricePoint Load (4.3ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 1000 OFFSET 4000
  ItemPricePoint Load (4.6ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 1000 OFFSET 5000
  ItemPricePoint Load (3.9ms)  SELECT `itemPricePoint`.* FROM `itemPricePoint` ORDER BY `itemPricePoint`.`quantity` ASC LIMIT 668 OFFSET 6000
=> nil
>>

Relevant section of my Gemfile:

####   RAILS ####
gem 'rails', '~> 4.0.2'
gem 'rake'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder'
gem 'arel'
gem 'json'

gem 'seed_dump', git: 'https://github.com/rroblak/seed_dump'

Fails on large datasets

Is there any way seed_dump could be changed to incrementally write to a file? I run out of heap space for large datasets.

Java heap space
org.jruby.RubyHash.allocFirst(RubyHash.java:292)
org.jruby.RubyHash.<init>(RubyHash.java:260)
org.jruby.RubyHash.<init>(RubyHash.java:254)
org.jruby.RubyHash.newHash(RubyHash.java:208)
rubyjit.ActiveRecord::Core$$init_internals_9FFDB6B00A6869C971C021A01FC653B4
... snipped

uninitialized constant Ckeditor::Orm

@ster โžœ  re3a rvm:(ruby-1.9.3@re3a) git:(master) โœ— rake db:seed:dump FILE=db/categories.rb --trace
** Invoke db:seed:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:seed:dump
Protection is disabled.
rake aborted!
uninitialized constant Ckeditor::Orm
/home/stereodenis/work/re3a/app/models/ckeditor/asset.rb:2:in `<class:Asset>'
/home/stereodenis/work/re3a/app/models/ckeditor/asset.rb:1:in `<top (required)>'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:48:in `block in loadModels'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:39:in `each'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:39:in `loadModels'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/gems/seed_dump-0.4.1/lib/seed_dump/perform.rb:159:in `run'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/gems/seed_dump-0.4.1/lib/tasks/seed_dump.rake:6:in `block (3 levels) in <top (required)>'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/stereodenis/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `<main>'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/bin/ruby_noexec_wrapper:14:in `eval'
/home/stereodenis/.rvm/gems/ruby-1.9.3-p194@re3a/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:seed:dump

Missing models when dumping

The problem is new to me, after using this gem for a long time this happened first time:
I am developing the project using RefineryCMS and using Page-Images gems. For some reason seed_dump does not do Refinery::ImagePage.create! command in seeds.rb (but there are all other commands, including something like Refinery::Testimonials::Testimonial::Translation.create!).
But it created the necessary command when I manually type
bundle exec rake db:seed:dump APPEND=true MODELS='Refinery::ImagePage'

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.