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

Upgrade fails in Step 4 "Backing up database" #15636

Open
2 tasks done
DomingoSneed opened this issue Oct 8, 2024 · 3 comments
Open
2 tasks done

Upgrade fails in Step 4 "Backing up database" #15636

DomingoSneed opened this issue Oct 8, 2024 · 3 comments

Comments

@DomingoSneed
Copy link

Debug mode

Describe the bug

Attempting to upgrade to current version of SnipeIT. Running update script crashes partway through and aborts the upgrade.

Issue occurs in Step 4, that backup of the database fails with a lengthy string of error messages.

Full print out of upgrade process is in screenshots section.

Reproduction steps

  1. Update PHP on IIS to v8.31.12
  2. Run git fetch -a on web server
  3. Run git pull on same server
  4. Run php upgrade.php
  5. Upgrade crashes in Step 4

Expected behavior

Upgrade to complete was expected result.

Screenshots

PS C:\inetpub\wwwroot\snipeit> php upgrade.php

WELCOME TO THE SNIPE-IT UPGRADER!

This script will attempt to:

  • validate some very basic .env file settings
  • check your PHP version and extension requirements
  • check directory permissions
  • do a git pull to bring you to the latest version
  • run composer install to get your vendors up to date
  • run migrations to get your schema up to date
  • clear out old cache settings

Launching using branch: master
Found PHP requirements, will check for PHP > 8.1.0 and < 8.4.0

Proceed with upgrade? [y/N]: y

Skipping user check as it is not supported on Windows or Posix is not installed on this server.

STEP 1: Checking .env file:

  • Your .env is located at C:\inetpub\wwwroot\snipeit/.env

√ Your APP_KEY is not blank.
√ Your APP_URL is not null or blank. It is set to http://snipeit.granite.com
√ Your APP_URL is set to http://snipeit.granite.com and starts with the protocol (https:// or http://)
√ Your APP_URL (http://snipeit.granite.com) does not have a trailing slash.


STEP 2: Checking PHP requirements: (Required PHP >=8.1.0 - <8.4.0)

√ Current PHP version: (8.3.12) is at least 8.1.0 and less than 8.4.0! Continuing...
FYI: The php.ini used by this PHP is: C:\Program Files\PHP\v8.3.12\php.ini

Checking Required PHP extensions...

√ bcmath is installed!
√ curl is installed!
√ exif is installed!
√ fileinfo is installed!
√ gd is installed!
√ json is installed!
√ ldap is installed!
√ mbstring is installed!
√ mysqli is installed!
√ openssl is installed!
√ PDO is installed!

  • sodium is NOT installed, but is recommended...
    √ tokenizer is installed!
    √ xml is installed!
    √ zip is installed!

STEP 3: Checking directory permissions:

√ C:\inetpub\wwwroot\snipeit/bootstrap/cache is writable
√ C:\inetpub\wwwroot\snipeit/storage is writable
√ C:\inetpub\wwwroot\snipeit/storage/logs is writable
√ C:\inetpub\wwwroot\snipeit/storage/logs/laravel.log is writable
√ C:\inetpub\wwwroot\snipeit/storage/framework is writable
√ C:\inetpub\wwwroot\snipeit/storage/framework/cache is writable
√ C:\inetpub\wwwroot\snipeit/storage/framework/sessions is writable
√ C:\inetpub\wwwroot\snipeit/storage/framework/views is writable
√ C:\inetpub\wwwroot\snipeit/storage/app is writable
√ C:\inetpub\wwwroot\snipeit/storage/app/backups is writable
√ C:\inetpub\wwwroot\snipeit/storage/app/backup-temp is writable
√ C:\inetpub\wwwroot\snipeit/storage/private_uploads is writable
√ C:\inetpub\wwwroot\snipeit/public/uploads is writable


STEP 4: Backing up database:

--
TypeError

Carbon\Carbon::setLastErrors(): Argument #1 ($lastErrors) must be of type array, false given, called in C:\inetpub\wwwroot\snipeit\vendor\nesbot\carbon\src\Carbon\Traits\Creator.php on line 98

at C:\inetpub\wwwroot\snipeit\vendor\nesbot\carbon\src\Carbon\Traits\Creator.php:928
924▕ * @param array $lastErrors
925▕ *
926▕ * @return void
927▕ */
➜ 928▕ private static function setLastErrors(array $lastErrors)
929▕ {
930▕ static::$lastErrors = $lastErrors;
931▕ }
932▕

Whoops\Exception\ErrorException

Using ${var} in strings is deprecated, use {$var} instead

at C:\inetpub\wwwroot\snipeit\vendor\facade\ignition\src\SolutionProviders\MergeConflictSolutionProvider.php:52
48▕ }
49▕
50▕ protected function getCurrentBranch(string $directory): string
51▕ {
➜ 52▕ $branch = "'".trim(shell_exec("cd ${directory}; git branch | grep \* | cut -d ' ' -f2"))."'";
53▕
54▕ if ($branch === "''") {
55▕ $branch = 'current branch';
56▕ }

Symfony\Component\ErrorHandler\Error\FatalError

Uncaught Whoops\Exception\ErrorException: Using ${var} in strings is deprecated, use {$var} instead in C:\inetpub\wwwroot\snipeit\vendor\facade\ignition\src\SolutionProviders\MergeConflictSolutionProvider.php:52
Stack trace:
#0 C:\inetpub\wwwroot\snipeit\vendor\composer\ClassLoader.php(576): Whoops\Run->handleError()
#1 C:\inetpub\wwwroot\snipeit\vendor\composer\ClassLoader.php(576): include()
#2 C:\inetpub\wwwroot\snipeit\vendor\composer\ClassLoader.php(427): Composer\Autoload{closure}()
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#4 C:\inetpub\wwwroot\snipeit\vendor\facade\ignition\src\SolutionProviders\SolutionProviderRepository.php(50): class_implements()
#5 [internal function]: Facade\Ignition\SolutionProviders\SolutionProviderRepository->Facade\Ignition\SolutionProviders{closure}()
#6 C:\inetpub\wwwroot\snipeit\vendor\laravel\framework\src\Illuminate\Collections\Arr.php(717): array_filter()
#7 C:\inetpub\wwwroot\snipeit\vendor\laravel\framework\src\Illuminate\Collections\Collection.php(358): Illuminate\Support\Arr::where()
#8 C:\inetpub\wwwroot\snipeit\vendor\facade\ignition\src\SolutionProviders\SolutionProviderRepository.php(49): Illuminate\Support\Collection->filter()
#9 C:\inetpub\wwwroot\snipeit\vendor\nunomaduro\collision\src\Adapters\Laravel\IgnitionSolutionsRepository.php(36): Facade\Ignition\SolutionProviders\SolutionProviderRepository->getSolutionsForThrowable()
#10 C:\inetpub\wwwroot\snipeit\vendor\nunomaduro\collision\src\Writer.php(244): NunoMaduro\Collision\Adapters\Laravel\IgnitionSolutionsRepository->getFromThrowable()
#11 C:\inetpub\wwwroot\snipeit\vendor\nunomaduro\collision\src\Writer.php(123): NunoMaduro\Collision\Writer->renderSolution()
#12 C:\inetpub\wwwroot\snipeit\vendor\nunomaduro\collision\src\Handler.php(39): NunoMaduro\Collision\Writer->write()
#13 C:\inetpub\wwwroot\snipeit\vendor\filp\whoops\src\Whoops\Run.php(370): NunoMaduro\Collision\Handler->handle()
#14 [internal function]: Whoops\Run->handleException()
#15 {main}
thrown

at C:\inetpub\wwwroot\snipeit\vendor\facade\ignition\src\SolutionProviders\MergeConflictSolutionProvider.php:52
48▕ }
49▕
50▕ protected function getCurrentBranch(string $directory): string
51▕ {
➜ 52▕ $branch = "'".trim(shell_exec("cd ${directory}; git branch | grep \* | cut -d ' ' -f2"))."'";
53▕
54▕ if ($branch === "''") {
55▕ $branch = 'current branch';
56▕ }

Whoops\Exception\ErrorException

Using ${var} in strings is deprecated, use {$var} instead

at C:\inetpub\wwwroot\snipeit\vendor\facade\ignition\src\SolutionProviders\MergeConflictSolutionProvider.php:52
48▕ }
49▕
50▕ protected function getCurrentBranch(string $directory): string
51▕ {
➜ 52▕ $branch = "'".trim(shell_exec("cd ${directory}; git branch | grep \* | cut -d ' ' -f2"))."'";
53▕
54▕ if ($branch === "''") {
55▕ $branch = 'current branch';
56▕ }

Something went wrong with your backup. Aborting!

Snipe-IT Version

Version v6.3.3 - build 12903 (master)

Operating System

Windows Server 2019

Web Server

IIS

PHP Version

Upgrading from 7.4 to 8.3.12

Operating System

Windows

Browser

Edge

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

No response

Copy link

welcome bot commented Oct 8, 2024

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@DomingoSneed
Copy link
Author

DomingoSneed commented Oct 9, 2024

Have made some progress, but still not all the way there.

Following the steps given here: https://snipe-it.readme.io/docs/upgrading

This was the latest process:

  1. Stop web server
  2. Update PHP to 8.3.1
  3. Verify PHP 8.3.1 is in place and recognized with php -v
  4. Open Powershell as admin
  5. Navigate to snipeit roor folder
  6. Run composer install --no-dev --prefer-source
  7. composer dump-autoload
  8. php artisan migrate (FAILS WITH ERRORS)
  9. php artisan config:clear
  10. php artisan config:cache

This is the errors thrown when attempting to run php artisan migrate:

Illuminate\Database\QueryException

could not find driver (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as size, table_comment as comment, engine as engine, table_collation as collation from information_schema.tables where table_schema = 'snipeit' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)

at vendor\laravel\framework\src\Illuminate\Database\Connection.php:829
825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
826▕ );
827▕ }
828▕
➜ 829▕ throw new QueryException(
830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
831▕ );
832▕ }
833▕ }

1 vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:65
PDOException::("could not find driver")

2 vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:65
PDO::__construct()

I ran php upgrade.php just to see what would happen, and I am presented with the pre-flight page.

Pre-flight page states:

D'oh! Looks like we can't connect to your database. Please update your database settings in your .env file. Your database says: could not find driver (Connection: mysql, SQL: select 2 + 2)

Gonna poke around to see if I can figure out what that means.

Snipe-IT Documentation
🚧 If you run into any issues upgrading...: Please check the Common Issues > Installation/Upgrading Issues section which provides solutions for commonly encountered installation / upgrading problems. Always backup your database and .env file before upgrading. We try very hard to make sure that al...

@DomingoSneed
Copy link
Author

I got it.

The very last step appears to be uncommenting this line in the php.ini file:

extension=pdo_mysql

After uncommenting that line and performing a server restart, php artisan migrate succeeded. Followed that with php upgrade.php and the upgrade fully ran. Site came back up on v7.0.13.

Hopefully this can help anyone else who runs into the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant