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

Database migration fails with PostgreSQL from 2.3.0 to 2.4.0 #891

Closed
bootc opened this issue Nov 8, 2020 · 3 comments · Fixed by #892
Closed

Database migration fails with PostgreSQL from 2.3.0 to 2.4.0 #891

bootc opened this issue Nov 8, 2020 · 3 comments · Fixed by #892
Labels
Milestone

Comments

@bootc
Copy link

bootc commented Nov 8, 2020

How Shlink is set-up

  • Shlink Version: 2.4.0 (upgrading from 2.3.0)
  • PHP Version: 7.4.11
  • How do you serve Shlink: Docker image
  • Database engine used: PostgreSQL

Summary

Creating fresh database if needed...
[2020-11-08T15:54:58.900254+00:00] [NULL] Shlink.INFO - Successfully acquired the "db:create" lock.
[2020-11-08T15:54:58.900565+00:00] [NULL] Shlink.INFO - Expiration defined for "db:create" lock for "90" seconds.
Updating database...
[2020-11-08T15:54:59.035655+00:00] [NULL] Shlink.INFO - Successfully acquired the "db:migrate" lock.
[2020-11-08T15:54:59.035919+00:00] [NULL] Shlink.INFO - Expiration defined for "db:migrate" lock for "90" seconds.

In ProcessHelper.php line 110:
                                                                               
  The command "'/usr/local/bin/php' 'vendor/doctrine/migrations/bin/doctrine-  
  migrations.php' 'migrations:migrate' '--no-interaction'" failed.             
                                                                               
  Exit Code: 255(Unknown error)                                                
                                                                               
  Working directory: /etc/shlink                                               
                                                                               
  Output:                                                                      
  ================                                                             
  [notice] Migrating up to ShlinkMigrations\Version20201102113208              
                                                                               
  Fatal error: Uncaught TypeError: Return value of ShlinkMigrations\Version20  
  201102113208::resolveOneApiKeyId() must be of the type string or null, int   
  returned in /etc/shlink/data/migrations/Version20201102113208.php:75         
  Stack trace:                                                                 
  #0 /etc/shlink/data/migrations/Version20201102113208.php(51): ShlinkMigrati  
  ons\Version20201102113208->resolveOneApiKeyId(Object(Doctrine\DBAL\Driver\P  
  DO\Statement))                                                               
  #1 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/D  
  balExecutor.php(190): ShlinkMigrations\Version20201102113208->postUp(Object  
  (ProxyManagerGeneratedProxy\__PM__\Doctrine\DBAL\Schema\Schema\Generatedbb2  
  d4e145a264026b8338fe2ecf3d239))                                              
  #2 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/Version/D  
  balExecutor.php(99): Doctrine\Migrations\Version\DbalExecutor->executeMigra  
  tion(Object(Doctrine\Migrations\Metadata\MigrationPlan), Object(Doctrine\Mi  
  grations\Version\ExecutionResult), Object(Doctrine\Migrations\MigratorConfi  
  guration))                                                                   
  #3 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigra  
  tor.php(98): Doctrine\Migrations\Version\DbalExecutor->execute(Object(Doctr  
  ine\Migrations\Metadata\MigrationPlan), Object(Doctrine\Migrations\Migrator  
  Configuration))                                                              
  #4 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigra  
  tor.php(71): Doctrine\Migrations\DbalMigrator->executePlan(Object(Doctrine\  
  Migrations\Metadata\MigrationPlanList), Object(Doctrine\Migrations\Migrator  
  Configuration))                                                              
  #5 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/DbalMigra  
  tor.php(148): Doctrine\Migrations\DbalMigrator->executeMigrations(Object(Do  
  ctrine\Migrations\Metadata\MigrationPlanList), Object(Doctrine\Migrations\M  
  igratorConfiguration))                                                       
  #6 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Con  
  sole/Command/MigrateCommand.php(197): Doctrine\Migrations\DbalMigrator->mig  
  rate(Object(Doctrine\Migrations\Metadata\MigrationPlanList), Object(Doctrin  
  e\Migrations\MigratorConfiguration))                                         
  #7 /etc/shlink/vendor/symfony/console/Command/Command.php(258): Doctrine\Mi  
  grations\Tools\Console\Command\MigrateCommand->execute(Object(Symfony\Compo  
  nent\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Cons  
  oleOutput))                                                                  
  #8 /etc/shlink/vendor/symfony/console/Application.php(920): Symfony\Compone  
  nt\Console\Command\Command->run(Object(Symfony\Component\Console\Input\Argv  
  Input), Object(Symfony\Component\Console\Output\ConsoleOutput))              
  #9 /etc/shlink/vendor/symfony/console/Application.php(266): Symfony\Compone  
  nt\Console\Application->doRunCommand(Object(Doctrine\Migrations\Tools\Conso  
  le\Command\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInpu  
  t), Object(Symfony\Component\Console\Output\ConsoleOutput))                  
  #10 /etc/shlink/vendor/symfony/console/Application.php(142): Symfony\Compon  
  ent\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvI  
  nput), Object(Symfony\Component\Console\Output\ConsoleOutput))               
  #11 /etc/shlink/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Co  
  nsole/ConsoleRunner.php(94): Symfony\Component\Console\Application->run()    
  #12 /etc/shlink/vendor/doctrine/migrations/bin/doctrine-migrations.php(43):  
   Doctrine\Migrations\Tools\Console\ConsoleRunner::run(Array, Object(Doctrin  
  e\Migrations\DependencyFactory))                                             
  #13 /etc/shlink/vendor/doctrine/migrations/bin/doctrine-migrations.php(44):  
   Doctrine\Migrations\{closure}()                                             
  #14 {main}                                                                   
    thrown in /etc/shlink/data/migrations/Version20201102113208.php on line 7  
  5                                                                            
                                                                               
                                                                               
  Error Output:                                                                
  ================                                                             
  [error] Migration ShlinkMigrations\Version20200105165647 skipped during Pre  
  -Checks. Reason: "New columns already exist"                                 
  [error] Migration ShlinkMigrations\Version20200106215144 skipped during Exe  
  cution. Reason: "Old columns do not exist"                                   
  [error] Migration ShlinkMigrations\Version20200323190014 skipped during Exe  
  cution. Reason: "Unknown Reason"                                             
  [error] Migration ShlinkMigrations\Version20200503170404 skipped during Exe  
  cution. Reason: "Unknown Reason"                                             
  [error] Migration ShlinkMigrations\Version20201102113208 failed during Post  
  -Checks. Error: "Return value of ShlinkMigrations\Version20201102113208::re  
  solveOneApiKeyId() must be of the type string or null, int returned"         
                                                                               

db:migrate

Current behavior

Expected behavior

How to reproduce

@bootc bootc added the bug label Nov 8, 2020
@acelaya
Copy link
Member

acelaya commented Nov 8, 2020

I see the problem. Thanks for reporting.

@acelaya acelaya added this to the 2.4.1 milestone Nov 8, 2020
acelaya added a commit to acelaya-forks/shlink that referenced this issue Nov 10, 2020
acelaya added a commit to acelaya-forks/shlink that referenced this issue Nov 10, 2020
@acelaya
Copy link
Member

acelaya commented Nov 10, 2020

Hey @bootc, I have just released v2.4.1, which includes a fix for this. Just skip v2.4.0 and go directly to v2.4.1 to get the migrations run.

If you use the docker image, then you need to wait for this to finish https://github.com/shlinkio/shlink/actions/runs/356443417

@bootc
Copy link
Author

bootc commented Nov 10, 2020

Thanks, the new version's migrations did seem to work and all is well again. Thanks again for a quick fix!

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

Successfully merging a pull request may close this issue.

2 participants