Bug 412629

Summary: Akonadi refuses to start after upgrade to PostgreSQL 12: column "version" of relation "schemaversiontable" already exists
Product: [Frameworks and Libraries] Akonadi Reporter: Karl-Johan Karlsson <creideiki+kdebugs>
Component: serverAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: holgersson, Martin, sfbarbee, sknauss, stefano.crocco
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: attachment-29246-0.html

Description Karl-Johan Karlsson 2019-10-05 08:40:14 UTC
SUMMARY
After upgrading PostgreSQL to version 12, and migrating the database according to https://userbase.kde.org/Akonadi/Postgres_update, trying to start Akonadi fails with:

org.kde.pim.akonadiserver: Starting up the Akonadi Server...
org.kde.pim.akonadiserver: Running DB initializer
org.kde.pim.akonadiserver: "\nSql error: ERROR:  column \"version\" of relation \"schemaversiontable\" already exists\n(42701) QPSQL: Unable to create query\nQuery: ALTER TABLE SchemaVersionTable ADD COLUMN version INTEGER NOT NULL DEFAULT 0"
org.kde.pim.akonadiserver: Unable to initialize database.
waiting for server to shut down.... done
server stopped

This is the same error message as in bug 409234, but not the same bug, since that one is about Qt 5.13 and I am on Qt 5.12.5.

I tried deleting $HOME/.local/share/akonadi/db_data/ and restarting Akonadi, which works, creating a new database. But I would prefer not having to re-download several GB of IMAP mailboxes.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 19.08.1
(available in About System)
KDE Plasma Version: 5.16.5
KDE Frameworks Version: 5.62.0
Qt Version: 5.12.5
Comment 1 Christophe Marin 2019-10-10 15:31:26 UTC
*** Bug 412818 has been marked as a duplicate of this bug. ***
Comment 2 Sandro Knauß 2019-10-10 18:20:12 UTC
Keep in mind, that even Qt does not support Postgres 12 atm, so in first glance there needs to be a bug filed against Qt:

https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/sqldrivers/psql/qsql_psql.cpp#n1080

also in Debian this bug is reported:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=941763
Comment 3 stuart 2019-10-10 19:02:09 UTC
Created attachment 123136 [details]
attachment-29246-0.html

Ok, I didn't suspect that since it is communicating with the database.
Just that the query fails and Akonadi shuts down.

On Thu, Oct 10, 2019 at 9:20 PM Sandro Knauß <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=412629
>
> Sandro Knauß <sknauss@kde.org> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                  CC|                            |sknauss@kde.org
>              Status|REPORTED                    |CONFIRMED
>      Ever confirmed|0                           |1
>
> --- Comment #2 from Sandro Knauß <sknauss@kde.org> ---
> Keep in mind, that even Qt does not support Postgres 12 atm, so in first
> glance
> there needs to be a bug filed against Qt:
>
>
> https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/sqldrivers/psql/qsql_psql.cpp#n1080
>
> also in Debian this bug is reported:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=941763
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 4 Christophe Marin 2019-10-19 10:50:49 UTC
FTR: https://codereview.qt-project.org/c/qt/qtbase/+/277205
Comment 5 Martin Steigerwald 2019-11-02 09:16:01 UTC
Does the fix in 

libqt5sql5-psql: basic support postgresql-12
https://bugs.debian.org/941763

fix this issue or not?

Or in other words: Has this been fixed or is it still an issue? I am asking, cause this bug report is still open.
Comment 6 holgersson 2019-11-02 22:45:36 UTC
(In reply to Martin Steigerwald from comment #5)
> Does the fix in 
> 
> libqt5sql5-psql: basic support postgresql-12
> https://bugs.debian.org/941763
> 
> fix this issue or not?
> 
> Or in other words: Has this been fixed or is it still
> an issue? I am asking, cause this bug report is still open.

This looks like the upstream patch we have in Gentoo[1],
so I think the issue is fixed, yes. As this bugtracker
seems to allow me to close this bug I’ll give it a try.

In case someone still has issues please re-open it.

[1] https://bugs.gentoo.org/696870, see second patch