rroblak / seed_dump Goto Github PK
View Code? Open in Web Editor NEWRails 4/5 task to dump your data to db/seeds.rb
License: MIT License
Rails 4/5 task to dump your data to db/seeds.rb
License: MIT License
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?
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?
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 :)
Using Ruby 1.9.2 and Rails 3. Getting this error even after adding seed_dump to Gemfile and doing a separate gem install.
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.
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.
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!
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:in
dumpModels'
/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:in
block (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:in
block 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:in
execute'
/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:in
mon_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:in
invoke'
/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:in
block (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:in
block 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:in
top_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:in
standard_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
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
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.
๐
At the moment I do not see the option to include the :id and the timestamps. They are excluded by default, but in my situation I want those too.
Is there an option that I overlooked? (This is version 3.1.0)
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...)
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.
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
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.
If any fields are serialize, the dump prints out the class, rather than calling load or dump.
rails 3.0.8
rake 0.9.2
Thanks,
Philip
It would be nice if it could skip validation on the models, a use case for this would be use with devise for example.
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 }
])
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.
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.
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)
Is it possible to get a dump of the last latest records rather than the earliest?
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
When I try and run this in a greenfield rails 4 app, I get an error about the use of attr_accessible (which is deprecated in Rails 4 in preference of strong parameters).
We use a gem that provides support for a composite primary key on a table. Would it be possible to make this gem still work if composite keys are used?
Them gem we are using is here:
https://github.com/composite-primary-keys/composite_primary_keys
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?
no error. no output and seeds.rb is untouched.
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.
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 >
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.
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)
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!
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?
I've tried setting TIMESTAMPS to false but it keeps including the timestamps anyway.
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 []' 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:in
block (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:in
block 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:in
each_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:in
block 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: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: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:in
block (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:in
block 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:in
execute'
/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:in
mon_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:in
invoke'
/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:in
block (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:in
block 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:in
top_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
Is there a way to get the records of the join tables from a has_and_belongs_to_many
association?
For example, I'd like to get the assemblies_parts
dumped in addition to assemblies
and parts
in the rails example: http://guides.rubyonrails.org/association_basics.html#the-has_and_belongs_to_many-association
How to skip specific model? I don't want to list it all, except one.
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.
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
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?
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'
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
In your examples you don't have created_at, updated_at, but they are included in the default dumps and I don't see a way to exclude fields in the options
@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
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.