K
K
Konstantin Tolmachev2018-03-09 08:36:09
MySQL
Konstantin Tolmachev, 2018-03-09 08:36:09

How to load more than 500 entries in the seeder?

Good day, a question arose, ran into the border of 500 records during seeding. I read that this is a restriction at the Mysql level, not lara. I decided that it is possible to load data in chunks, i.e. using transactions. I made this code,

try
    {
      DB::beginTransaction();
      for($i=1;$i<=6;$i++)
      {
        for ($b = 1; $b<=4;$b++)
        {
          $t = $group->subgroups()->get()->random();
          \App\Models\Schedule::create([
            'week' => $week,
            'day_of_week' => $i,
            'city_id' => 1,
            'group_id' => $group->id,
            'corps_id' => $group->corps_id,
            'discipline_id' => $t->discipline_id,
            'teacher_id' => $t->teacher_id,
            'rooms'  => rand(10,350),
            'lesson_priority' => $b,
          ]);
        }
      }
      DB::commit();
    }
    catch (\Exception $exception)
    {
      DB::rollBack();
    }

But the limitation remains the same. Although, in theory, it should have left, because. I load data in small pieces. Can anyone suggest how to load the data correctly in this case? It seems that I read the doc carefully, but apparently I'm missing something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2018-03-09
@Kostik_1993

HZ, but maybe you are doing something wrong. I did a sider and 100 thousand. records without any restrictions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question