Skip to content

Commit

Permalink
Need to slice my insert up for testing with sqlite. See commentary here
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldrennen committed May 26, 2019
1 parent a38c71d commit ae1dfd2
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/Console/IsoLanguageCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,26 @@ protected function insertIsoLanguageCodesWithEloquent( string $localFilePath ) {

array_shift( $rows ); // Remove the header row

try {
\MichaelDrennen\Geonames\Models\IsoLanguageCodeWorking::insert( $rows );
} catch ( Exception $exception ) {
Log::error( '',
$exception->getMessage(),
'database',
$this->connectionName );
$this->error( $exception->getMessage() );
throw $exception;

/**
* @see https://github.com/laravel/framework/issues/50
*/
$slicer = floor(999 / sizeof($rows[0]));
$slices = array_chunk($rows, $slicer);
foreach ($slices as $slice) {
try {
\MichaelDrennen\Geonames\Models\IsoLanguageCodeWorking::insert( $slice );
} catch ( Exception $exception ) {
Log::error( '',
$exception->getMessage(),
'database',
$this->connectionName );
$this->error( $exception->getMessage() );
throw $exception;
}
}


$this->enableKeys( self::TABLE_WORKING );
Schema::connection( $this->connectionName )->dropIfExists( self::TABLE );
Schema::connection( $this->connectionName )->rename( self::TABLE_WORKING, self::TABLE );
Expand Down

0 comments on commit ae1dfd2

Please sign in to comment.