user3921996
user3921996

Reputation: 149

Clone database or run sql dump on the fly in laravel 4

I have a big project in laravel 4, and i need to make new database with lot of tables on the fly. I can make empty database on the fly, but how to fill it up with tables? I cant use migrations on the fly, because this application have lot of permissions, so user cant pass them.

First option is to clone empty database (empty from data but with tables). Second option is run sql dump file on the fly.

Can someone explain me how to do that?

Upvotes: 2

Views: 444

Answers (1)

Sojan Jose
Sojan Jose

Reputation: 3238

Laravel provides an option to fill the database through seeding . check the docs .

Laravel also includes a simple way to seed your database with test data using seed classes. All seed classes are stored in app/database/seeds. Seed classes may have any name you wish, but probably should follow some sensible convention, such as UserTableSeeder, etc. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.

after defining the seed class . you can seed the database through the command

php artisan db:seed

check this blog post on how to use seeing and also faker library to prefill databased with real like test data.

if you can't use command line. you can call the seed command from your code . check this thread .

Upvotes: 0

Related Questions