How to seed a one file only with sequelize-cli?
To run a specific seed indicate --seed <seed_file_nams.js>
:
sequelize db:seed --seed my_seeder_file.js
Adonis: How do I seed only a specific file?
Looks like I should have run adonis seed --help
. Here is how to do it in production.
adonis seed --files IndustrySeeder.js --force
Laravel 4 db seed specific seeder file
You can call individual seed classes by their class name.
From the docs.
By default, the db:seed command runs the DatabaseSeeder class, which
may be used to call other seed classes. However, you may use the
--class option to specify a specific seeder class to run individually:
php artisan db:seed --class=ProductTableSeeder
In the example above, the ProductTableSeeder
class should exist in database/seeds
.
Is it possible to rake db:seed just one model? - Rails 4
I think you should use your custom rake task to build what you want. The task rake db:seed is just a helper to get you organised from the beginning. But you can also add under YOUR_APP/lib/tasks your custom rake tasks.
http://cobwwweb.com/how-to-write-a-custom-rake-task
Is there a way to db:seed only one table in Rails?
With below custom rake file, you can have multiple seed files in db/seeds/
folder.
# lib/tasks/custom_seed.rake
# lib/tasks/custom_seed.rake
namespace :db do
namespace :seed do
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].each do |filename|
task_name = File.basename(filename, '.rb').intern
task task_name => :environment do
load(filename)
end
end
task :all => :environment do
Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].sort.each do |filename|
load(filename)
end
end
end
end
Then, in order to run specific seed file, you can just run
rake db:seed:seed_file_name
To run all the seeds file with order in that db/seeds
folder, run below command
rake db:seed:all
Adding a custom seed file
Start by creating a separate directory to hold your custom seeds – this example uses db/seeds
. Then, create a custom task by adding a rakefile to your lib/tasks
directory:
# lib/tasks/custom_seed.rake
namespace :db do
namespace :seed do
Dir[Rails.root.join('db', 'seeds', '*.rb')].each do |filename|
task_name = File.basename(filename, '.rb')
desc "Seed " + task_name + ", based on the file with the same name in `db/seeds/*.rb`"
task task_name.to_sym => :environment do
load(filename) if File.exist?(filename)
end
end
end
end
This rakefile accepts the name of a seed file in the db/seeds
directory (excluding the .rb
extension), then runs it as it would run seeds.rb
. You can execute the rake task by issuing the following from the command line:
rake db:seed:file_name # Name of the file EXCLUDING the .rb extension
Update: Now it should also list the seed tasks when running rake --tasks
or rake -T
.
Related Topics
Clear an Input Field With Reactjs
Regex With Space and Letters Only
How to Convert File to Base64 in JavaScript
How to Append Value to an Array Only If Not Exists and Remove It If Not
Wait for Asynchronous Functions to Finish in Angular
Add Two Numbers and Display Result in Textbox With JavaScript
Jquery Ajax Post Results in 500 Internal Server Error
Javascript - Auto Click on a Button on Page Load
Jquery Validation Code for Not Allowed Only Blank Space in Textbox
How to Loop Through Json Array and Get Specific Values
Print Function Not Working in Chrome
How to Save .Xlsx Data to File as a Blob
How to Output a Pdf Buffer to Browser Using Nodejs
Hide Menu Sidebar When Clicking Outside the Bar or the Button
Javascript String With New Line - But Not Using \N
Method for Splitting String into Separate Cells in Sheets/App Script