Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setup database without seed data

I need to setup my database with tables and such, but in certain cases I don't want my seed data to be loaded. I also don't want to delete or move my db/seeds.rb file every time I want to ignore my seed data.

Is there a way to perform the tasks of rake db:setup and ignore seed data?

like image 616
mschallert Avatar asked Jul 11 '12 21:07

mschallert


People also ask

What is seed data in database?

Data seeding is the process of populating a database with an initial set of data. There are several ways this can be accomplished in EF Core: Model seed data. Manual migration customization. Custom initialization logic.

Why do we seed data?

Database seeding is populating a database with an initial set of data. It's common to load seed data such as initial user accounts or dummy data upon initial setup of an application.

What is a seed file in SQL?

A seed file will contain dummy data that populates your database so that you can test if your models and associations are working the way you want them to. This file can contain whatever information you want so have fun with it!

Why we use seeding in rails?

Rails seed files are a useful way of populating a database with the initial data needed for a Rails project. The Rails db/seeds. rb file contains plain Ruby code and can be run with the Rails-default rails db:seed task.


1 Answers

Yes. Just use the following two commands:

rake db:create
rake db:schema:load

What rake db:setup does is just creating the database (db:create), loading the data from db/schema.rb (db:schema:load) and then inserting the seed data (db:seed). You can do these steps separatly.

like image 132
iblue Avatar answered Oct 12 '22 00:10

iblue