CRUD
CRUD copied to clipboard
[Bug] Install command counts user even with `--no-interaction`?
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 fromusers)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!
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;

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.
@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 = '???';
...
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.
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
@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 ๐