mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Fixed purchase/consume page handling when FEATURE_FLAG_STOCK_LOCATION_TRACKING is disabled (fixes #1829)
This commit is contained in:
23
migrations/8888.php
Normal file
23
migrations/8888.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// This migration is always executed (on every migration run, not only once)
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
// When FEATURE_FLAG_STOCK_LOCATION_TRACKING is disabled,
|
||||
// some places assume that there exists a location with id 1,
|
||||
// so make sure that this location is available in that case
|
||||
if (!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
{
|
||||
$db = $this->getDatabaseService()->GetDbConnection();
|
||||
|
||||
if ($db->locations()->where('id', 1)->count() === 0)
|
||||
{
|
||||
// Create 2 default quantity units
|
||||
$defaultLocation = $db->locations()->createRow([
|
||||
'id' => 1,
|
||||
'name' => 'Default'
|
||||
]);
|
||||
$defaultLocation->save();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user