From 5c6a410bd8afe5a2bd5ec173849a4ec8fad02b73 Mon Sep 17 00:00:00 2001 From: Andre Belafronte Date: Thu, 17 Mar 2022 14:24:25 -0300 Subject: [PATCH] =?UTF-8?q?fix(upgrade):=20atualiza=20l=C3=B3gica=20de=20m?= =?UTF-8?q?igra=C3=A7=C3=A3o=20para=20v2.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atualiza processo de migração da v1.4 para v2.1 refs: #112 --- .../NFEioServiceInvoices/lib/Configuration.php | 3 +++ .../lib/Models/ProductCode/Repository.php | 12 +++++++----- .../lib/Models/ServiceInvoices/Repository.php | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/addons/NFEioServiceInvoices/lib/Configuration.php b/modules/addons/NFEioServiceInvoices/lib/Configuration.php index d5a5abe..4366486 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Configuration.php +++ b/modules/addons/NFEioServiceInvoices/lib/Configuration.php @@ -232,6 +232,8 @@ public function activate() \NFEioServiceInvoices\Migrations\Migrations::migrateServiceInvoices(); // executa as rotinas de sql para a model ServiceInvoices $serviceInvoicesRepo->createServiceInvoicesTable(); + // garante que em uma migração de v1.4 para v2.1 as novas colunas estejam presentes + $serviceInvoicesRepo->upgrade_to_2_1_0(); // rotinas de ativação da model ProductCode (tabela productcode) $productCodeRepo = new \NFEioServiceInvoices\Models\ProductCode\Repository(); @@ -239,6 +241,7 @@ public function activate() \NFEioServiceInvoices\Migrations\Migrations::migrateProductCodes(); // executa as rotinas de sql para a model ProductCode $productCodeRepo->createProductCodeTable(); + $productCodeRepo->upgrade_to_2_1_0(); // rotinas de ativação da model ClientConfiguration (tabela custom_configs) $clientConfigurationRepo = new \NFEioServiceInvoices\Models\ClientConfiguration\Repository(); diff --git a/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php b/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php index eaacd79..f6373ca 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php +++ b/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php @@ -156,12 +156,14 @@ public function getIssHeldByRelId($relId) public function upgrade_to_2_1_0() { + // verifica se a tabela existe if (Capsule::schema()->hasTable($this->tableName)) { - if (!Capsule::schema()->hasColumn($this->tableName, 'iss_held')) { - Capsule::schema()->table($this->tableName, function ($table) { - $table->float('iss_held', 5, 2)->after('code_service')->nullable(); - }); - } + // se não houver coluna adiciona + if (!Capsule::schema()->hasColumn($this->tableName, 'iss_held')) { + Capsule::schema()->table($this->tableName, function ($table) { + $table->float('iss_held', 5, 2)->after('code_service')->nullable(); + }); + } } } } \ No newline at end of file diff --git a/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php b/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php index 6c05058..4ad509a 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php +++ b/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php @@ -174,6 +174,7 @@ public function hasInvoices($id) } /** * Atualiza as colunas necessarias para a versão 2.1.0 + * @author Andre Bellafronte * @version 2.1.0 * @return void */