mercredi 20 mars 2019

Laravel Command to migrate tables not copying all records

I have created a way to migrate data from one DB to another. The problem comes into play where there are about 15k rows and Laravel only copies about 12k or 12.5k or 13k. It ranges each time. Its like it times out somehow but there are no errors.

All my rows are set as nullable and I did set limits on the top incase.

public function handle()
    {

        ini_set('memory_limit', '-1');
        ini_set('max_execution_time', 300); //300 seconds = 5 minutes
        ini_set('max_execution_time', 0); // for infinite time of execution
        set_time_limit(555550);


        $this->info('Starting Import Report');
        $oldReports = DB::connection('old')->select("SELECT * FROM `report` ORDER by ReportID");

        //dd(count($oldReports));
        $i = 1;
        foreach ($oldReports as $oldReport) {

            $this->info('#'  . $i . ' --- Report ID: '. $oldReport->ReportID);

            $report = new Report();
            $report->id = $oldReport->ReportID;
            $report->file_id = $oldReport->FileID;
            $report->report = $oldReport->Report;
            $report->type_of_report = $oldReport->TypeOfReport;
            $report->report_date = $oldReport->ReportDate;


            $report->created_at = \Carbon\Carbon::now();
            $report->updated_at = null;

            $report->save();

            $i++;

        }


        $this->info('Completed Import Report');
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire