1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for created_at and updated_at timestamps in migration

This commit is contained in:
= 2021-05-05 19:45:31 +10:00
parent b6c538564e
commit 46d5b84fb7
2 changed files with 48 additions and 1 deletions

View File

@ -488,6 +488,14 @@ class Import implements ShouldQueue
)
);
if(array_key_exists('created_at', $modified))
$client->created_at = $modified['created_at'];
if(array_key_exists('updated_at', $modified))
$client->updated_at = $modified['updated_at'];
$client->save(['timestamps' => false]);
$client->contacts()->forceDelete();
if (array_key_exists('contacts', $resource)) { // need to remove after importing new migration.json
@ -891,6 +899,14 @@ class Import implements ShouldQueue
QuoteFactory::create($this->company->id, $modified['user_id'])
);
if(array_key_exists('created_at', $modified))
$quote->created_at = $modified['created_at'];
if(array_key_exists('updated_at', $modified))
$quote->updated_at = $modified['updated_at'];
$quote->save(['timestamps' => false]);
$old_user_key = array_key_exists('user_id', $resource) ?? $this->user->id;
$key = "quotes_{$resource['id']}";
@ -957,6 +973,14 @@ class Import implements ShouldQueue
PaymentFactory::create($this->company->id, $modified['user_id'])
);
if(array_key_exists('created_at', $modified))
$payment->created_at = $modified['created_at'];
if(array_key_exists('updated_at', $modified))
$payment->updated_at = $modified['updated_at'];
$payment->save(['timestamps' => false]);
if (array_key_exists('company_gateway_id', $resource) && isset($resource['company_gateway_id']) && $resource['company_gateway_id'] != 'NULL') {
$payment->company_gateway_id = $this->transformId('company_gateways', $resource['company_gateway_id']);
$payment->save();
@ -1319,6 +1343,14 @@ class Import implements ShouldQueue
$task = Task::Create($modified);
if(array_key_exists('created_at', $modified))
$task->created_at = $modified['created_at'];
if(array_key_exists('updated_at', $modified))
$task->updated_at = $modified['updated_at'];
$task->save(['timestamps' => false]);
$old_user_key = array_key_exists('user_id', $resource) ?? $this->user->id;
$this->ids['tasks'] = [
@ -1399,6 +1431,14 @@ class Import implements ShouldQueue
$expense = Expense::Create($modified);
if(array_key_exists('created_at', $modified))
$expense->created_at = $modified['created_at'];
if(array_key_exists('updated_at', $modified))
$expense->updated_at = $modified['updated_at'];
$expense->save(['timestamps' => false]);
$old_user_key = array_key_exists('user_id', $resource) ?? $this->user->id;
$key = "expenses_{$resource['id']}";

View File

@ -71,7 +71,14 @@ class InvoiceMigrationRepository extends BaseRepository
$model->fill($tmp_data);
$model->status_id = $tmp_data['status_id'];
$model->save();
if(array_key_exists('created_at', $data))
$model->created_at = $data['created_at'];
if(array_key_exists('updated_at', $data))
$model->updated_at = $data['updated_at'];
$model->save(['timestamps' => false]);
if (array_key_exists('documents', $data)) {
$this->saveDocuments($data['documents'], $model);