Skip to content

Commit

Permalink
release: module update from ifthenpay/dev_prestashop_8 (ifthenpay/dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocouto-ifthenpay committed Aug 14, 2023
1 parent a5e4c02 commit a93c138
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions ifthenpay/classes/Config/IfthenpaySql.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public function __construct($userPaymentMethods = null)

private function migrate_from_17_to_8()
{
$count = 0;
$tablesToCheck = array(
array('name' => _DB_PREFIX_ . 'ifthenpay_multibanco', 'oldColumnName' => 'request_id'),
array('name' => _DB_PREFIX_ . 'ifthenpay_mbway', 'oldColumnName' => 'id_transacao'),
Expand All @@ -129,18 +128,15 @@ private function migrate_from_17_to_8()

foreach ($tablesToCheck as $tableInfo) {

$columnCheckResult = checkColumnsExistence($tableInfo['name'], $tableInfo['oldColumnName']);
$columnCheckResult = $this->checkColumnsExistence($tableInfo['name'], $tableInfo['oldColumnName']);

if ($columnCheckResult == 1) {
$alterColumnResponse = alterColumnName($tableInfo['name'], $tableInfo['oldColumnName']);
$count += $alterColumnResponse ? 1 : 0;
$this->alterColumnName($tableInfo['name'], $tableInfo['oldColumnName']);
}
}

return $count > 0 ? true : false;
}

function checkColumnsExistence($tableName, $oldColumnName)
private function checkColumnsExistence($tableName, $oldColumnName)
{
$query = 'SELECT COUNT(*) AS column_exists
FROM information_schema.columns
Expand All @@ -152,7 +148,7 @@ function checkColumnsExistence($tableName, $oldColumnName)
return $count > 0 ? 1 : 0;
}

function alterColumnName($tableName, $oldColumnName)
private function alterColumnName($tableName, $oldColumnName)
{
$newColumnName = 'transaction_id';

Expand All @@ -162,8 +158,6 @@ function alterColumnName($tableName, $oldColumnName)
$result = \Db::getInstance()->execute($alterQuery);

IfthenpayLogProcess::addLog('Ran migration script (alterColumnName()) for table ' . $tableName . ' with result code = ' . $result, IfthenpayLogProcess::INFO, 0);

return $result == 1 ? true : false;
}

private function createShopSql()
Expand Down

0 comments on commit a93c138

Please sign in to comment.