Laravel - seeding large SQL file

后端 未结 3 1915
后悔当初
后悔当初 2021-02-08 01:41

A memory exhaustion happens when I run my DB seed script in production.

Below is my seed script.

class MembershipTableSeeder extends Seeder 
{
    public         


        
3条回答
  •  被撕碎了的回忆
    2021-02-08 02:42

    The problem happens because when using Db::unprepared it also logs the query to the laravel.log file, making in background much more actions then you think, from this side you have memory exhaust. If you are not running the safe mode I would stick to executing the console command like this:

    exec("mysql -u ".\Config::get('database.mysql.user')." -p".\Config::get('database.mysql.password')." ".\Config::get('database.mysql.database')." < script.sql")
    

提交回复
热议问题