mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Move FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT
to per product option (closes #1753)
This commit is contained in:
18
migrations/0162.php
Normal file
18
migrations/0162.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
// Migrate the old config.php setting FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT
|
||||
// to the new product option treat_opened_as_out_of_stock
|
||||
// New and old default was/is enabled, so only disable it for all existing products when it was disabled
|
||||
|
||||
if (!defined('GROCY_FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT'))
|
||||
{
|
||||
define('GROCY_FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT', true);
|
||||
}
|
||||
|
||||
if (!GROCY_FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT)
|
||||
{
|
||||
$this->getDatabaseService()->ExecuteDbStatement('UPDATE products SET treat_opened_as_out_of_stock = 0');
|
||||
$this->getDatabaseService()->ExecuteDbStatement("INSERT INTO user_settings (user_id, key, value) SELECT id, 'product_presets_treat_opened_as_out_of_stock', '0' FROM users");
|
||||
}
|
Reference in New Issue
Block a user