YunoHost-Apps / wallabag2_ynh

Wallabag v2 package for YunoHost
https://www.wallabag.org/
GNU Affero General Public License v3.0
63 stars 13 forks source link

Upgrade failed with DB error - Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_368A4209A76ED395`; check that it exists #161

Closed Jaxom99 closed 1 year ago

Jaxom99 commented 1 year ago

Describe the bug

When upgrading the app, upgrade fails with this error. I don't think I made any change to database or other settings of the app. Also the app is broken now, displays only a white page, and booklet doesn't work anymore...

Thanks for anyone spending some time to look it up :smile_cat:

Context

Steps to reproduce

yunohost tools upgrade apps when wallabag2 is in the list of upgradable apps.

Expected behavior

The app should upgrade to latest version.

Logs

link : yunohost log share 20230127-100910-app_upgrade-wallabag2

Relevant extract :

Info: [###############++++.] > Reconfiguring wallabag...
Warning: 11:14:12 ERROR     [console] Error thrown while running command "--no-interaction --env=prod doctrine:migrations:migrate". Message: "An exception occurred while executing 'ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY FK_368A4209A76ED395':
Warning: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_368A4209A76ED395`; check that it exists" ["exception" => Doctrine\DBAL\Exception\DriverException { …},"command" => "--no-interaction --env=prod doctrine:migrations:migrate","message" => """  An exception occurred while executing 'ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY FK_368A4209A76ED395':\n  \n  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_368A4209A76ED395`; check that it exists  """]
Warning: In AbstractMySQLDriver.php line 128:
Warning:   An exception occurred while executing 'ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY FK_368A4209A76ED395':
Warning:   SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_368A4209A76ED395`; check that it exists
Warning: In Exception.php line 18:
Warning:   SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_368A4209A76ED395`; check that it exists
Warning: In PDOConnection.php line 141:
Warning:   SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP FOREIGN KEY `FK_368A4209A76ED395`; check that it exists
Warning: doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]
Warning: [Error] Upgrade failed.
lapineige commented 1 year ago

You wallabag was installed before 2018 I guess ?

That an issue with old installations.

There is a manual fix, or a branch that is supposed to fix it for you. https://github.com/YunoHost-Apps/wallabag2_ynh/pull/133 yunohost app upgrade wallabag2 -u https://github.com/nicofrand/wallabag2_ynh/tree/upgrade-database-scheme

Jaxom99 commented 1 year ago

Oh, thanks for pointing this out, will try ASAP. Is this traced somewhere ? Should it be ?

Is there anything I must do afterwards to "fall back" to stable releases of the app ?

lapineige commented 1 year ago

The is an open issue and 2 related pull requests, but it's a bit of a mess to follow :sweat_smile:

After upgrading to that branch, do a normal upgrade (to the lastest version).

Be sure to have a proper backup before :) (the upgrade will do an automatic one, but they are overwritten after 2 of them)

Jaxom99 commented 1 year ago

And bingo, fully upgraded. Thanks again, long-live free software and self-hosting !

lapineige commented 1 year ago

Great !