mirror of
https://github.com/grocy/grocy.git
synced 2025-08-28 17:10:11 +00:00
Squashed commit
Fixed recipe ingredient costs/calories calculation when having different QUs and when only_check_single_unit_in_stock is set (fixes #2529) Added a new column "Product picture" on /products (closes #2640) Fixed partly opening stock entries stock_id handling (fixes #2391)
This commit is contained in:
22
migrations/0242.php
Normal file
22
migrations/0242.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
// Assign a new stock_id to all opened stock entries where there is also an unopened one with the same stock_id
|
||||
$db = $this->getDatabaseService();
|
||||
|
||||
$sql = 'SELECT s1.id
|
||||
FROM stock s1
|
||||
WHERE IFNULL(s1.open, 0) = 1
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM stock s2
|
||||
WHERE s2.stock_id = s1.stock_id
|
||||
AND IFNULL(s2.open, 0) = 0
|
||||
)';
|
||||
|
||||
$rows = $db->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$db->ExecuteDbStatement('UPDATE stock SET stock_id = \'' . uniqid() . '\' WHERE id = ' . $row->id);
|
||||
}
|
Reference in New Issue
Block a user