Skip to content

Commit

Permalink
fix(upgrade): atualiza lógica de migração para v2.1
Browse files Browse the repository at this point in the history
Atualiza processo de migração da v1.4 para v2.1

refs: #112
  • Loading branch information
andrekutianski committed Mar 17, 2022
1 parent 2123e08 commit 5c6a410
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions modules/addons/NFEioServiceInvoices/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ 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();
// verifica e realiza possiveis migrações durante o processo de ativação para a model ProductCode
\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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 5c6a410

Please sign in to comment.