Fixes for migration data checks

This commit is contained in:
David Bomba 2020-11-25 13:59:23 +11:00
parent 2f4b46e435
commit c2b07c3ebc
3 changed files with 19 additions and 5 deletions

View File

@ -819,7 +819,7 @@ class Import implements ShouldQueue
if (isset($modified['invoices'])) {
foreach ($modified['invoices'] as $key => $invoice) {
if($modified['amount'] >= 0)
if($this->tryTransformingId('invoices', $invoice['invoice_id']))
$modified['invoices'][$key]['invoice_id'] = $this->transformId('invoices', $invoice['invoice_id']);
else{
$modified['credits'][$key]['credit_id'] = $this->transformId('credits', $invoice['invoice_id']);
@ -1289,6 +1289,7 @@ class Import implements ShouldQueue
public function transformId($resource, string $old): int
{
if (! array_key_exists($resource, $this->ids)) {
info(print_r($resource,1));
throw new Exception("Resource {$resource} not available.");
}
@ -1299,6 +1300,19 @@ class Import implements ShouldQueue
return $this->ids[$resource]["{$resource}_{$old}"]['new'];
}
private function tryTransformingId($resource, string $old): ?int
{
if (! array_key_exists($resource, $this->ids)) {
return false;
}
if (! array_key_exists("{$resource}_{$old}", $this->ids[$resource])) {
return false;
}
return $this->ids[$resource]["{$resource}_{$old}"]['new'];
}
/**
* Process & handle user_id.
*

View File

@ -57,7 +57,7 @@ class StartMigration implements ShouldQueue
// public $maxExceptions = 2;
public $backoff = 86430;
//public $backoff = 86430;
public function __construct($filepath, User $user, Company $company)
{

View File

@ -38,14 +38,14 @@ return [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 900000,
'retry_after' => 90000000,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 900000,
'retry_after' => 90000000,
'block_for' => 0,
],
@ -63,7 +63,7 @@ return [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 900000,
'retry_after' => 90000000,
'block_for' => null,
],