Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: database migration error after upgrading to version 4 #2287

Closed
Bonerserk opened this issue Aug 1, 2023 · 1 comment
Closed

Bug: database migration error after upgrading to version 4 #2287

Bonerserk opened this issue Aug 1, 2023 · 1 comment

Comments

@Bonerserk
Copy link

Hi.
After upgrading from 3.3.2 version to 4 I got database migration error.
I'm using linuxserver image.
After upgrading to new version I got this error.
NOTICE: fpm is running, pid 216 NOTICE: ready to handle connections WARNING: [pool www] child 244 exited with code 124 after 50.877382 seconds from start

I tried to start an empty 3.3.2 instance of Grocy, adding a product and then migrate to 4 version. All worked.

So I activated the dev mode with my 3.3.2 database to get logs.
First error was
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: users.username

So I removed all users and related tables record.

After this the error was:
`Error source:

```
/app/www/services/DatabaseService.php:32
```
Error message:
```
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: locations.name
```
Stack trace:
```
#0 /app/www/services/DatabaseService.php(32): PDO->exec()
#1 /app/www/services/DemoDataGeneratorService.php(220): Grocy\Services\DatabaseService->ExecuteDbStatement()
#2 /app/www/controllers/SystemController.php(35): Grocy\Services\DemoDataGeneratorService->PopulateDemoData()
#3 /app/www/packages/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Grocy\Controllers\SystemController->Root()
#4 /app/www/packages/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke()
#5 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle()
#6 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle()
#7 /app/www/packages/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle()
#8 /app/www/packages/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run()
#9 /app/www/middleware/LocaleMiddleware.php(16): Slim\Routing\RouteRunner->handle()
#10 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\LocaleMiddleware->__invoke()
#11 /app/www/middleware/AuthMiddleware.php(32): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#12 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\AuthMiddleware->__invoke()
#13 /app/www/packages/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#14 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\RoutingMiddleware->process()
#15 /app/www/packages/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#16 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process()
#17 /app/www/middleware/CorsMiddleware.php(27): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#18 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\CorsMiddleware->__invoke()
#19 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#20 /app/www/packages/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle()
#21 /app/www/packages/slim/slim/Slim/App.php(183): Slim\App->handle()
#22 /app/www/app.php(109): Slim\App->run()
#23 /app/www/public/index.php(45): require_once('...')
#24 {main}
```
System info:
```
{
"grocy_version": {
"Version": "4.0.0",
"ReleaseDate": "2023-07-29"
},
"php_version": "8.2.8",
"sqlite_version": "3.41.2",
"os": "Linux 6.1.41-0-rpi #1-Alpine SMP PREEMPT Tue Jul 25 07:59:02 UTC 2023 aarch64",
"client": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
}
````

After renaming all locations I got this error

SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: quantity_units.id

Here I stopped editing database.

How con I migrate to the new version maintaining my data.

Thanks!

@berrnd
Copy link
Member

berrnd commented Aug 1, 2023

I'm using linuxserver image.

None of the community contributed apps/integrations/tools are maintained here.

 

After upgrading to new version I got this error. [...]

Pretty obviously a general server message/error, nothing to reproduce that there, hence nothing to fix. This is the place for reproducible bugs and feature requests, not the support forum (README ref).

The usual problem (valid for any PHP application) could be: You use a slow machine (like a Raspberry Pi), your PHP execution is limited (general PHP/webserver configuration stuff), the migration took a little while longer due to the mentioned slow machine and/or much data => boom (something about 50+ seconds execution time is at least noticed in your referenced log message).

 

So I activated the dev mode with my 3.3.2 database to get logs.
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: users.username
SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: quantity_units.id

Well, really not a surprise since dev mode tries to populate demo data (config comment ref) and naturally this conflicts with any existing data and therefore can only work on an empty/fresh database. It's also nowhere stated to do that, so I can't really follow how you came to the conclusion that that's a good idea at all.

 

"php_version": "8.2.8",

After each and every release, I notice that reading seems to be harder and harder for more and more, but I also don't know what to do more. It's stated in README and on the changelog that only PHP 8.1 is supported, all of those errors can potentially also be caused by that. Please simply have a look at the changelog before updating, I guess that's a valid point for each and every software on this planet to avoid headaches. I'm not so into Docker, but I guess then even the maintainers of that image haven't had a tiny look at the changelog and README, cool.

@berrnd berrnd closed this as completed Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants