Skip to content
Prev Previous commit
Fix
  • Loading branch information
andrey-helldar committed Dec 15, 2023
commit 379476b3e485f5bc513f35b4ab3d67a49eda234a
16 changes: 9 additions & 7 deletions src/Console/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function runTransfer(): void
}

$this->truncateTable($table);
$this->migrateTable($table);
$this->migrateTable($table, $this->source->getPrimaryKey($table));
});

$this->displayMessage(PHP_EOL);
Expand All @@ -127,15 +127,17 @@ protected function truncateTable(string $table): void
}
}

protected function migrateTable(string $table): void
protected function migrateTable(string $table, string $column): void
{
Log::info('Transferring data from: ' . $table);

$this->builder($this->source(), $table)->chunk(1000, function (Collection $items) use ($table) {
$this->builder($this->target(), $table)->insert(
Arr::resolve($items)
);
});
$this->builder($this->source(), $table)
->orderBy($column)
->chunk(1000, function (Collection $items) use ($table) {
$items = Arr::resolve($items);

$this->builder($this->target(), $table)->insert($items);
});

$this->migrated[] = $table;
}
Expand Down