[Kmymoney-devel] How to upgrade the database

Christian Dávid christian-david at web.de
Mon Aug 11 17:46:29 UTC 2014


Hi Fernando,

sorry, I received your mail mutilated. This will make this mail hard to read 
and I manipulated some quotes to make it not that worse.

Am Sonntag, 10. August 2014, 18:01:37 schrieb Fernando Vilas:
> […]
> > Now I added a new column to kmmFieldInfo in MyMoneyDbDef::FileInfo(void)
> > using:
> > 
> > appendField(MyMoneyDbIntColumn("hiOnlineJobId", MyMoneyDbIntColumn::BIG,
> > UNSIGNED, false, false, 8));
> > 
> > First question: is that correct?
> > 
> > If I open KMyMoney with a sql-database it crashes because it tries to
> > select
> > the new column "hiOnlineJobId" (or even tags if the version is 6) before
> > it
> > updated the database.
> > 
> > I did some investigation and noticed that the upgradeToVx() methods call
> > readFileInfo() and writeFileInfo() quite often. But these methods use
> > m_db.m_tables["kmmFileInfo"].selectAllString(). This leads to the request
> > for
> > non-existing columns (-> exception -> crash).
> 
> Those methods are intended for a few of the more complex updates to the
> structure we made in the past. I think just rolling the version number
> will fix it, but I need to look harder at it.

No, setting the version correctly still leads to the same issue.

I even think, this behavior will prevent the upgrades to v1, and v7 as they 
call readFileInfo() and new columns were created in that versions. If you have 
to upgrade more versions than just on (vN -> vM | m >= n+2) it will even fail 
if you start with any version before v7 (= all possible update processes).

Actually the test databases which I just created (using master branch) 
identifies itself as version 6 but it should be v7. This indicates a bug in the 
upgrade process.

_ Solution _

I would recommend not to use readFileInfo() and writeFileInfo() in any upgrade 
methods anymore and just call writeFileInfo() at the end of the upgrade 
process. Also the m_hi…Id vars need to be set somewhere.

There was never a version released with database version 7 officially (it adds 
tags). Should I add my changes to version 7 as well? 

How is the database created if you create a new database from scratch:
1) Is the most recent database version created directly? Or
2) do you create a database of version 0 and then call all upgrade methods?


More information about the KMyMoney-devel mailing list