From 1271a23755da6e6a42424ef4a1d08a9a0d3a638f Mon Sep 17 00:00:00 2001 From: denisdulici Date: Sun, 9 Feb 2020 23:21:18 +0300 Subject: [PATCH] missing module update --- app/Listeners/Update/V20/Version200.php | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/app/Listeners/Update/V20/Version200.php b/app/Listeners/Update/V20/Version200.php index 510bf69a9..c07153d4e 100644 --- a/app/Listeners/Update/V20/Version200.php +++ b/app/Listeners/Update/V20/Version200.php @@ -259,6 +259,7 @@ class Version200 extends Listener $has_crm_companies = Schema::hasTable('crm_companies'); $has_crm_contacts = Schema::hasTable('crm_contacts'); $has_idea_soft_histories = Schema::hasTable('idea_soft_histories'); + $has_custom_fields_field_values = Schema::hasTable('custom_fields_field_values'); foreach ($customers as $customer) { $data = (array) $customer; @@ -312,6 +313,16 @@ class Version200 extends Listener 'model_type' => 'App\Models\Common\Contact', ]); } + + if ($has_custom_fields_field_values) { + DB::table('custom_fields_field_values') + ->where('model_id', $customer->id) + ->where('model_type', 'App\Models\Income\Customer') + ->update([ + 'model_id' => $contact_id, + 'model_type' => 'App\Models\Common\Contact', + ]); + } } Schema::drop('customers'); @@ -321,6 +332,8 @@ class Version200 extends Listener { $vendors = DB::table('vendors')->cursor(); + $has_custom_fields_field_values = Schema::hasTable('custom_fields_field_values'); + foreach ($vendors as $vendor) { $data = (array) $vendor; $data['type'] = 'vendor'; @@ -347,6 +360,16 @@ class Version200 extends Listener 'mediable_id' => $contact_id, 'mediable_type' => 'App\Models\Common\Contact', ]); + + if ($has_custom_fields_field_values) { + DB::table('custom_fields_field_values') + ->where('model_id', $vendor->id) + ->where('model_type', 'App\Models\Expense\Vendor') + ->update([ + 'model_id' => $contact_id, + 'model_type' => 'App\Models\Common\Contact', + ]); + } } Schema::drop('vendors'); @@ -419,6 +442,7 @@ class Version200 extends Listener $has_double_entry_ledger = Schema::hasTable('double_entry_ledger'); $has_project_revenues = Schema::hasTable('project_revenues'); + $has_custom_fields_field_values = Schema::hasTable('custom_fields_field_values'); foreach ($revenues as $revenue) { $payment_method = str_replace('offlinepayment.', 'offline-payments.', $revenue->payment_method); @@ -482,6 +506,16 @@ class Version200 extends Listener 'revenue_id' => $transaction_id, ]); } + + if ($has_custom_fields_field_values) { + DB::table('custom_fields_field_values') + ->where('model_id', $revenue->id) + ->where('model_type', 'App\Models\Income\Revenue') + ->update([ + 'model_id' => $transaction_id, + 'model_type' => 'App\Models\Banking\Transaction', + ]); + } } Schema::drop('revenues'); @@ -544,6 +578,7 @@ class Version200 extends Listener $has_double_entry_ledger = Schema::hasTable('double_entry_ledger'); $has_project_payments = Schema::hasTable('project_payments'); $has_receipts = Schema::hasTable('receipts'); + $has_custom_fields_field_values = Schema::hasTable('custom_fields_field_values'); foreach ($payments as $payment) { $payment_method = str_replace('offlinepayment.', 'offline-payments.', $payment->payment_method); @@ -615,6 +650,16 @@ class Version200 extends Listener 'payment_id' => $transaction_id, ]); } + + if ($has_custom_fields_field_values) { + DB::table('custom_fields_field_values') + ->where('model_id', $payment->id) + ->where('model_type', 'App\Models\Expense\Payment') + ->update([ + 'model_id' => $transaction_id, + 'model_type' => 'App\Models\Banking\Transaction', + ]); + } } Schema::drop('payments');