CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

[Bug] Install command counts user even with `--no-interaction`?

Open tabacitu opened this issue 3 years ago โ€ข 5 comments

Developer report on email:

With this new version my DO app platform build fails. Before that I manually install backpack with 'php artisan backpack:install --no-interaction', and it was working fine. But now the build run with the appplatform build and fail like this:

STEP 1 Installing Backpack CRUD: [2022-09-13 12:43:53] [2022-09-13 12:43:57] Publishing configs, views, js and css files ............................ DONE [2022-09-13 12:43:57] Creating users table ................................................... DONE [2022-09-13 12:43:57] Creating CheckIfAdmin middleware ....................................... DONE [2022-09-13 12:44:16] Installing Backpack Generators ......................................... DONE [2022-09-13 12:44:16] [2022-09-13 12:44:16] In Connection.php line 759: [2022-09-13 12:44:16]
[2022-09-13 12:44:16] SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregat
[2022-09-13 12:44:16] e from users)

Do you have any suggestions? I know it can't connect to the managed db, but when I run php artisan migrate, it can migrate the files, so the DB connection is fine, at least after the build fails :S

@promatik - it looks to me like we're counting users, even if --no-interaction is run? Is this true? Or what could be the cause of this?

Thanks!

tabacitu avatar Sep 13 '22 13:09 tabacitu

Wow, this is strange ...

Ok first, yes, even with --no-interaction it may count the users, because it's the default behaviour, count, and then it will default answer no to create admin users. But that is not an issue in my opinion...

Before that, the users table is created;

Image

How does the "Creating users table DONE" goes well, but the count gets a connection refused??? ๐Ÿคจ


I can remove the count when --no-interaction but this is a fix just for this user I think.

promatik avatar Sep 14 '22 13:09 promatik

@tabacitu can you please ask that user if his App\Models\User has a different connection or table?

class User extends Model {
    protected $connection = '???';
    protected $table = '???';
    ...

promatik avatar Sep 14 '22 13:09 promatik

Asked, will come back with answer.

Yeah, let's not do that query if it's not necessary. What if people run it on a DB with 100M users? Unlikely but... not needed.

tabacitu avatar Sep 15 '22 07:09 tabacitu

I told you guys from start that this user count is "pretty" but bound to bit us in the ass. https://github.com/Laravel-Backpack/CRUD/pull/4559#discussion_r935416830

That query is never necessary, it's just a "beautification" that we really don't need.

Please consider removing it entirely. ๐Ÿ™ƒ

Cheers

pxpm avatar Sep 15 '22 07:09 pxpm

@tabacitu @pxpm I was about to remove the info line, BUT ๐Ÿ˜… This developer will have this error anyway, if it's not while counting, it's while inserting ๐Ÿคทโ€โ™‚๏ธ

So I created this PR; https://github.com/Laravel-Backpack/CRUD/pull/4670 That aims to solve the issue from it's root!

If you guys agree with it, this one may be closed ๐Ÿ‘Œ

promatik avatar Sep 17 '22 00:09 promatik