statamic-redirect icon indicating copy to clipboard operation
statamic-redirect copied to clipboard

Cannot update addon - @php artisan statamic:install fails due to missing DB config

Open kgirzadas opened this issue 9 months ago • 13 comments

Attempting to update to the latest version of the addon using composer update triggers the @php artisan statamic:install command. However, this command fails with the following error:

Database connection [redirect-sqlite] not configured.

Our project does not use any database at all. In the Redirect addon configuration, both log_errors and log_hits are explicitly set to false. Despite this, the addon still attempts to access the redirect-sqlite database connection during installation, which results in the error.

This breaks the update workflow even for setups that intentionally avoid database usage.

kgirzadas avatar Apr 10 '25 09:04 kgirzadas

Same here - when running composer update:

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (Connection: mysql, SQL: select * from `cache` where `key` in (firefly_cache_statamic-js-statamic-redirect-{md5(cp.js?v=3a134ba732046a809a25dba48f11f75b)}))

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕ 
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

      +37 vendor frames 

  38  artisan:13
      Illuminate\Foundation\Application::handleCommand()

sunscreem avatar May 01 '25 11:05 sunscreem

@riasvdv I'm not keen on creating a database on this client project. Is this a requirement now?

sunscreem avatar May 01 '25 11:05 sunscreem

I just did a composer remove rias/statamic-redirect and a composer require rias/statamic-redirect and that has resolved this for me.

sunscreem avatar May 01 '25 11:05 sunscreem

Sussed it. I'd upgraded to laravel 11. I hadn't changed CACHE_DRIVER=file to CACHE_STORE=file in my env.

sunscreem avatar May 01 '25 13:05 sunscreem

I ended up running composer remove rias/statamic-redirect, running composer update and then running composer require rias/statamic-redirect. That got me past this issue.

michaeljberry avatar May 08 '25 15:05 michaeljberry

I ended up running composer remove rias/statamic-redirect, running composer update and then running composer require rias/statamic-redirect. That got me past this issue.

That workaround doesn’t fully solve the problem. I encounter the same issue again during the next composer update.

kgirzadas avatar May 21 '25 06:05 kgirzadas

Can confirm that yes - composer update breaks it again :(

sunscreem avatar Jun 02 '25 18:06 sunscreem

Could you share the full stacktrace from the exception? I can't seem to reproduce this myself

riasvdv avatar Jun 14 '25 09:06 riasvdv

Same problem here.

Removing and re-installing the package did not help, the same error will occur next time I run composer install (e.g. while building the docker container). The (external) database is not supposed to be available at this step, leading to the following "timeout expired" error (stacktrace anonymized):

15.37 Generating optimized autoload files
18.16 > Illuminate\Foundation\ComposerScripts::postAutoloadDump
18.21 > @php artisan package:discover --ansi
48.68 [2025-06-17 15:40:40] production.ERROR: SQLSTATE[08006] [7] connection to server at "xxxx" (xxxxx), port xxxx failed: timeout expired (Connection: pgsql, SQL: select exists (select 1 from pg_class c, pg_namespace n where n.nspname = 'public' and c.relname = 'redirects' and c.relkind in ('r', 'p') and n.oid = c.relnamespace))
....
48.68 #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(779): Illuminate\\Database\\Connection->runQueryCallback('select exists (...', Array, Object(Closure))
48.68 #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(398): Illuminate\\Database\\Connection->run('select exists (...', Array, Object(Closure))
48.68 #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(344): Illuminate\\Database\\Connection->select('select exists (...', Array, true)
48.68 #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(361): Illuminate\\Database\\Connection->selectOne('select exists (...', Array, true)
48.68 #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/PostgresBuilder.php(52): Illuminate\\Database\\Connection->scalar('select exists (...')
48.68 #5 /var/www/html/vendor/rias/statamic-redirect/src/RedirectServiceProvider.php(222): Illuminate\\Database\\Schema\\PostgresBuilder->hasTable('redirects')
48.68 #6 /var/www/html/vendor/rias/statamic-redirect/src/RedirectServiceProvider.php(117): Rias\\StatamicRedirect\\RedirectServiceProvider->bootRedirects()
48.68 #7 /var/www/html/vendor/statamic/cms/src/Statamic.php(362): Rias\\StatamicRedirect\\RedirectServiceProvider->Rias\\StatamicRedirect\\{closure}()
48.68 #8 /var/www/html/vendor/statamic/cms/src/Providers/AppServiceProvider.php(36): Statamic\\Statamic::runBootedCallbacks()
48.68 #9 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1194): Statamic\\Providers\\AppServiceProvider->Statamic\\Providers\\{closure}(Object(Illuminate\\Foundation\\Application))
48.68 #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1137): Illuminate\\Foundation\\Application->fireAppCallbacks(Array)
48.68 #11 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
48.68 #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(342): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application))
48.68 #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(474): Illuminate\\Foundation\\Application->bootstrapWith(Array)
48.68 #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(196): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
48.68 #15 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1235): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
48.68 #16 /var/www/html/artisan(13): Illuminate\\Foundation\\Application->handleCommand(Object(Symfony\\Component\\Console\\Input\\ArgvInput))
48.68 #17 {main}
...
48.68 #27 {main}
48.68 "} 
48.68 
48.69 In Connection.php line 825:
48.69                                                                                
48.69   SQLSTATE[08006] [7] connection to server at "xxxx" (xxx), port xxxx failed: timeo  
48.69   ut expired (Connection: pgsql, SQL: select exists (select 1 from pg_class c  
48.69   , pg_namespace n where n.nspname = 'public' and c.relname = 'redirects' and  
48.69    c.relkind in ('r', 'p') and n.oid = c.relnamespace))                        
48.69                                                                                
48.69 
48.70 In Connector.php line 66:
48.70                                                                                
48.70   SQLSTATE[08006] [7] connection to server at "xxxx" (xxxx), port xxxx failed: timeo  
48.70   ut expired                                                                   
48.70                                                                                
48.70 
48.72 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Temporary solution:

  • Either downgrade to a previous version
  • Or remove the lines
"@php artisan package:discover --ansi",
"@php artisan statamic:install --ansi"

from section scripts.post-autoload-dump in composer.json (durrrr)

FlxRobole avatar Jun 17 '25 14:06 FlxRobole

Possible that the latest version may help with this - if you add REDIRECT_RUN_MIGRATIONS=false to your env, it will not automatically run migrations on the boot() call.

Also, you can add this to composer config if you're still having trouble with it:

"extra": {
    "laravel": {
        "dont-discover": [
            "statamic/redirects"
        ]
    },
}

macaws avatar Jul 18 '25 16:07 macaws

I'm experiencing this, too. Any progress?

imbwaldo avatar Sep 03 '25 17:09 imbwaldo

@imbwaldo have you tried this in ENV? REDIRECT_RUN_MIGRATIONS=false

macaws avatar Sep 03 '25 18:09 macaws

Thanks, @macaws. I did see that, above, but it seemed like it maybe didn't address the underlying issue (whatever that issue may be). But if that actually does fix the problem—not just painting over it—I'll give it a shot.

imbwaldo avatar Sep 04 '25 16:09 imbwaldo