mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Automate manual update steps (closes #2384)
This commit is contained in:
@@ -63,8 +63,6 @@ See [grocy/grocy-docker](https://github.com/grocy/grocy-docker) or [linuxserver/
|
|||||||
|
|
||||||
- Overwrite everything with the [latest release](https://releases.grocy.info/latest) while keeping the `data` directory
|
- Overwrite everything with the [latest release](https://releases.grocy.info/latest) while keeping the `data` directory
|
||||||
- Check `config-dist.php` for new configuration options and add them to your `data/config.php` where appropriate (the default values from `config-dist.php` will be used for not in `data/config.php` defined settings)
|
- Check `config-dist.php` for new configuration options and add them to your `data/config.php` where appropriate (the default values from `config-dist.php` will be used for not in `data/config.php` defined settings)
|
||||||
- Empty the `data/viewcache` directory
|
|
||||||
- Visit the main route once to apply database migrations ([see below](https://github.com/grocy/grocy#database-migrations))
|
|
||||||
|
|
||||||
If you run Grocy on Linux, there is also `update.sh` (remember to make the script executable (`chmod +x update.sh`) and ensure that you have `unzip` installed) which does exactly this and additionally creates a backup (`.tgz` archive) of the current installation in `data/backups` (backups older than 60 days will be deleted during the update).
|
If you run Grocy on Linux, there is also `update.sh` (remember to make the script executable (`chmod +x update.sh`) and ensure that you have `unzip` installed) which does exactly this and additionally creates a backup (`.tgz` archive) of the current installation in `data/backups` (backups older than 60 days will be deleted during the update).
|
||||||
|
|
||||||
@@ -137,7 +135,7 @@ See that plugin or `plugins/DemoBarcodeLookupPlugin.php` for a commented example
|
|||||||
|
|
||||||
### Database migrations
|
### Database migrations
|
||||||
|
|
||||||
Database schema migration is automatically done when visiting the root (`/`) route (click on the logo in the left upper edge).
|
Database schema migration is done when visiting the root (`/`) route (click on the logo in the left upper edge) as needed and is also triggered automatically if the version has changed (so when an update has been made).
|
||||||
|
|
||||||
_Please note: Database migrations are supposed to work between releases, not between every commit. If you want to run the current `master` branch (which is the development version), you need to handle that (and more) yourself._
|
_Please note: Database migrations are supposed to work between releases, not between every commit. If you want to run the current `master` branch (which is the development version), you need to handle that (and more) yourself._
|
||||||
|
|
||||||
|
23
app.php
23
app.php
@@ -52,9 +52,28 @@ catch (EInvalidConfig $ex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create data/viewcache folder if it doesn't exist
|
// Create data/viewcache folder if it doesn't exist
|
||||||
if (!file_exists(GROCY_DATAPATH . '/viewcache'))
|
$viewcachePath = GROCY_DATAPATH . '/viewcache';
|
||||||
|
if (!file_exists($viewcachePath))
|
||||||
{
|
{
|
||||||
mkdir(GROCY_DATAPATH . '/viewcache');
|
mkdir($viewcachePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty data/viewcache when the version changed (so when an update was done) and trigger database migrations
|
||||||
|
$releaseHash = hash_file('sha256', __DIR__ . '/version.json');
|
||||||
|
$releaseHashCacheFile = $viewcachePath . "/$releaseHash.txt";
|
||||||
|
if (!file_exists($releaseHashCacheFile))
|
||||||
|
{
|
||||||
|
EmptyFolder($viewcachePath);
|
||||||
|
touch($releaseHashCacheFile);
|
||||||
|
|
||||||
|
if (function_exists('opcache_reset'))
|
||||||
|
{
|
||||||
|
opcache_reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schema migration happens on the root route, so redirect to there
|
||||||
|
header('Location: ' . (new UrlManager(GROCY_BASE_URL))->ConstructUrl('/'));
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup base application
|
// Setup base application
|
||||||
|
@@ -62,7 +62,8 @@
|
|||||||
- Dialogs can now be closed with the `ESC` key on the keyboard
|
- Dialogs can now be closed with the `ESC` key on the keyboard
|
||||||
- There is no longer a close button at the bottom (outside of the displayed `iframe`) and instead one at the top right corner of the dialog
|
- There is no longer a close button at the bottom (outside of the displayed `iframe`) and instead one at the top right corner of the dialog
|
||||||
- Wide dialogs (e.g. all showing a table, like showing stock entries of a product from the stock overview more/context menu per line) now use the full screen width
|
- Wide dialogs (e.g. all showing a table, like showing stock entries of a product from the stock overview more/context menu per line) now use the full screen width
|
||||||
- Improved handling of the initial field focus
|
- Improved the handling of the initial field focus on form pages
|
||||||
|
- The previously manually necessary update steps (e.g. emptying the `data/viewcache` directory) are now fully automated, so no need to do this manually after this and future updates
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
|
@@ -262,3 +262,19 @@ function require_frontend_packages(array $packages)
|
|||||||
|
|
||||||
$GROCY_REQUIRED_FRONTEND_PACKAGES = array_unique(array_merge($GROCY_REQUIRED_FRONTEND_PACKAGES, $packages));
|
$GROCY_REQUIRED_FRONTEND_PACKAGES = array_unique(array_merge($GROCY_REQUIRED_FRONTEND_PACKAGES, $packages));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EmptyFolder($folderPath)
|
||||||
|
{
|
||||||
|
foreach(glob("{$folderPath}/*") as $item)
|
||||||
|
{
|
||||||
|
if(is_dir($item))
|
||||||
|
{
|
||||||
|
EmptyFolder($item);
|
||||||
|
rmdir($item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unlink($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user