Skip to content

Commit

Permalink
Merge branch 'hotfix/0.14.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
polosson committed Jul 12, 2021
2 parents ba01524 + b599c7f commit dd90f45
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Tous les changements notables sur le projet sont documentés dans ce fichier.

Ce projet adhère au principe du [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.14.3 (2021-07-12)

- Corrige la migration qui posait problème avec les préfixes de table (#198).

## 0.14.2 (2021-07-09)

- Améliore les perfs des parcs : pas d'injection du montant total même pour le getOne().
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.2
0.14.3
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
use Phinx\Migration\AbstractMigration;

use Robert2\API\Config as Config;

class AddStateToInventoryMaterialUnits extends AbstractMigration
{
public function up()
Expand Down Expand Up @@ -31,16 +33,21 @@ public function up()
])
->save();

$units = $this->fetchAll(
"SELECT imu.`id`, mu.`state`
FROM inventory_material_units AS imu
LEFT JOIN material_units AS mu ON imu.`material_unit_id` = mu.`id`"
);
$prefix = Config\Config::getSettings('db')['prefix'];

$units = $this->fetchAll(sprintf(
'SELECT imu.`id`, mu.`state`
FROM `%1$sinventory_material_units` AS imu
LEFT JOIN `%1$smaterial_units` AS mu ON imu.`material_unit_id` = mu.`id`',
$prefix
));
foreach ($units as $unit) {
$this->execute(vsprintf(
// phpcs:ignore Generic.Files.LineLength
'UPDATE `inventory_material_units` SET `state_previous`="%2$s", `state_current`="%2$s" WHERE `id` = %1$d',
[$unit['id'], $unit['state']]
$this->execute(sprintf(
'UPDATE `%1$sinventory_material_units`
SET `state_previous` = "%3$s", `state_current` = "%3$s" WHERE `id` = %2$d',
$prefix,
$unit['id'],
$unit['state']
));
}

Expand Down

0 comments on commit dd90f45

Please sign in to comment.