snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.04k stars 3.18k forks source link

500 | Server Error #9883

Open jmanaks1 opened 3 years ago

jmanaks1 commented 3 years ago

Please confirm you have done the following before posting your bug report:

Describe the bug Current snipe it version v4.6.15 Trying to upgrade one by one version and able to upgrade till v4.6.18. Getting error "500 | Server error" while upgrading from v4.6.18 to v4.7.0

Expected behavior Expecting upgrade without error.

Screenshots image

Server (please complete the following information):

Desktop (please complete the following information):

Error Messages `storage/logs/laravel.logs.

8 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(834): Illuminate\Container\Container->resolveDependencies(Array)

9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(681): Illuminate\Container\Container->build('App\\Http\\Middle...')

10 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(785): Illuminate\Container\Container->resolve('App\\Http\\Middle...', Array, true)

11 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Foundation\Application->resolve('App\\Http\\Middle...', Array)

12 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(770): Illuminate\Container\Container->make('App\\Http\\Middle...', Array)

13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(209): Illuminate\Foundation\Application->make('App\\Http\\Middle...')

14 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(183): Illuminate\Foundation\Http\Kernel->terminateMiddleware(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))

15 /var/www/html/public/index.php(63): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response))

16 {main}

Additional context

Add any other context about the problem here.

Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.

welcome[bot] commented 3 years ago

👋 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.

joeldeteves commented 3 years ago

Did you remember to run the database migrations after upgrading?

  1. Exec into the container

  2. php artisan migrate

Also: I believe this issue is fixed via the docker entrypoint script in newer versions, so once you're on v5+ you shouldn't need to do this anymore (I haven't so far).

jmanaks1 commented 3 years ago

I have run the "php artisan migrate" command in snipeit docker container & getting following error.

root@3f23e930dfff:/var/www/html# php artisan migrate


In PDOConnection.php line 24:

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

joeldeteves commented 3 years ago

That error usually happens when you’re using a mismatched version of PHP, but that doesn’t make sense if you’re using the official Docker image.

Being that 4.6.18 is nearly 3 years old, you aren’t doing yourself any favours by trying to upgrade in this manner

I would back up the database and try a newer version, maybe 4.9.5 if you insist on trying a minor before a major

jmanaks1 commented 3 years ago

Appreciate your quick reply!

I tried with v4.9.5 and no issue with that, snipeit runs successfully with all data.

But when I tried to latest version after v4.9.5, it gives me "500 | Server error". So as I ran "php artisan migrate" command in snipeit container & got following errors:

Should I try any other version instead of latest after v4.9.5? (currently running containers are snipeit v4.9.5 & Mysql 5.6) Please suggest.

Error after running "php artisan migrate" Command:

root@4928eda94217:/var/www/html# php artisan migrate -v


Migrating: 2018_07_28_023826_create_checkout_acceptances_table

Illuminate\Database\QueryException : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'checkout_acceptances' already exists (SQL: create table checkout_acceptances (id int unsigned not null auto_increment primary key, checkoutable_type varchar(191) not null, checkoutable_id bigint unsigned not null, assigned_to_id int null, signature_filename varchar(191) null, accepted_at timestamp null, declined_at timestamp null, created_at timestamp null, updated_at timestamp null, deleted_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB)

at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) {

669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673|

Exception trace:

1 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'checkout_acceptances' already exists") /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18

2 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException)) /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:114

3 PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'checkout_acceptances' already exists") /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:112

4 PDOStatement::execute() /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:112

5 Doctrine\DBAL\Driver\PDOStatement::execute() /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463

6 Illuminate\Database\Connection::Illuminate\Database{closure}("create table checkout_acceptances (id int unsigned not null auto_increment primary key, checkoutable_type varchar(191) not null, checkoutable_id bigint unsigned not null, assigned_to_id int null, signature_filename varchar(191) null, accepted_at timestamp null, declined_at timestamp null, created_at timestamp null, updated_at timestamp null, deleted_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB", []) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:662

7 Illuminate\Database\Connection::runQueryCallback("create table checkout_acceptances (id int unsigned not null auto_increment primary key, checkoutable_type varchar(191) not null, checkoutable_id bigint unsigned not null, assigned_to_id int null, signature_filename varchar(191) null, accepted_at timestamp null, declined_at timestamp null, created_at timestamp null, updated_at timestamp null, deleted_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB", [], Object(Closure)) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:629

8 Illuminate\Database\Connection::run("create table checkout_acceptances (id int unsigned not null auto_increment primary key, checkoutable_type varchar(191) not null, checkoutable_id bigint unsigned not null, assigned_to_id int null, signature_filename varchar(191) null, accepted_at timestamp null, declined_at timestamp null, created_at timestamp null, updated_at timestamp null, deleted_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB", [], Object(Closure)) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:464

9 Illuminate\Database\Connection::statement("create table checkout_acceptances (id int unsigned not null auto_increment primary key, checkoutable_type varchar(191) not null, checkoutable_id bigint unsigned not null, assigned_to_id int null, signature_filename varchar(191) null, accepted_at timestamp null, declined_at timestamp null, created_at timestamp null, updated_at timestamp null, deleted_at timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB") /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:97

10 Illuminate\Database\Schema\Blueprint::build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar)) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:290

11 Illuminate\Database\Schema\Builder::build(Object(Illuminate\Database\Schema\Blueprint)) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:167

12 Illuminate\Database\Schema\Builder::create("checkout_acceptances", Object(Closure)) /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261

13 Illuminate\Support\Facades\Facade::__callStatic("create") /var/www/html/database/migrations/2018_07_28_023826_create_checkout_acceptances_table.php:29

14 CreateCheckoutAcceptancesTable::up() /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:392

15 Illuminate\Database\Migrations\Migrator::Illuminate\Database\Migrations{closure}() /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:401

16 Illuminate\Database\Migrations\Migrator::runMigration(Object(CreateCheckoutAcceptancesTable), "up") /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:200

17 Illuminate\Database\Migrations\Migrator::runUp("/var/www/html/database/migrations/2018_07_28_023826_create_checkout_acceptances_table.php") /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:165

18 Illuminate\Database\Migrations\Migrator::runPending([]) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:110

19 Illuminate\Database\Migrations\Migrator::run([]) /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:71

20 Illuminate\Database\Console\Migrations\MigrateCommand::handle() /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36

21 Illuminate\Container\BoundMethod::Illuminate\Container{closure}() /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:37

22 Illuminate\Container\Util::unwrapIfClosure(Object(Closure)) /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93

23 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure)) /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37

24 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), []) /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:590

25 Illuminate\Container\Container::call() /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:134

26 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) /var/www/html/vendor/symfony/console/Command/Command.php:255

27 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:121

28 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) /var/www/html/vendor/symfony/console/Application.php:1009

29 Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) /var/www/html/vendor/symfony/console/Application.php:273

30 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) /var/www/html/vendor/symfony/console/Application.php:149

31 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:93

32 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:131

33 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) /var/www/html/artisan:35

joeldeteves commented 3 years ago

First off, make sure you have a backup of your database before you proceed any further.

Second, read the error. It is quite clear ‘table already exists.’

Possibly you had a failed migration attempt in the past where the migration was interrupted somehow?

There are some suggestions in this thread on how to fix it https://stackoverflow.com/questions/26077458/laravel-migration-table-already-exists-but-i-want-to-add-new-not-the-older

Basically you will need to roll back the migration & try again

php artisan migrate:rollback

php artisan migrate

If that fails, you’ll need to edit the database & drop the tables that its whining about (hence why I said “back up your database”)

Stack Overflow
Laravel Migration table already exists, but I want to add new not the older
I previously created users table. Now I have created a new migration to create a new books table inside my schema. When I try to run the command php artisan migrate It shows: [Illuminate\Database\
jmanaks1 commented 3 years ago

Thank you for your quick support!

I tried those above mentioned steps and successfully able to run " php artisan migrate" but still issue " 500 | server error " is there.

Should I upgrade mysql container also (currently running mysql 5.6) for latest version of snipeit?

or should I try to upgrade with some other version instead of latest after v 4.5.9?

Currently running container are mysql 5.6 and snipeit 4.5.9.

Please suggest.

Thank you!

jmanaks1 commented 3 years ago

Someone can provide any solution on this please?

uberbrady commented 3 years ago

I mean, I guess you could drop the checkout_acceptances table - but like @joeldeteves said, make sure you have a backup first.

If you want to do that, then you can run DROP TABLE checkout_acceptances - but I suspect you’re going to have further migration problems after that too.

You can also try and directly insert into the migrations table - INSERT INTO migrations (batch,migration) VALUES (1,’2019_01_23_45678_name_of_failed_migration’) - but we’re into very scary territory here.

jmanaks1 commented 3 years ago

Hello Brady,

Actually migration is not getting failed so no error coming after migration but while browsing with URL gives "500 | Server error".

root@927fab48adb6:/var/www/html# php artisan migrate


Nothing to migrate. root@927fab48adb6:/var/www/html#