[Interest] Best way to handle database migrations on QML

Daniel França daniel.franca at gmail.com
Fri Oct 23 13:21:28 CEST 2015


Any idea?

Em qui, 22 de out de 2015 às 13:30, Daniel França <daniel.franca at gmail.com>
escreveu:

> Hi guys,
> I'm developing a single file ORM library for QML.
> For now it's doing most of the main operations on tables.
> You can see it here, with a basic documentation as well:
> https://github.com/danielfranca/quickmodel
>
> But now I'm trying to implement a way to have migrations, and can't find a
> good solution for that.
>
> I don't want anything complex, my goal will be to have something that you
> simply change the table you want and increase the database version (then
> the tables gonna be recreated and populated with existent data).
>
> I know about the changeVersion method on LocalStorage:
> http://doc.qt.io/qt-5/qtquick-localstorage-qmlmodule.html
>
> But I'm not sure about how to use it.
> i.e:
> I call *openDatabaseSync *with version 1.0 and create my tables.
> Then I change it to version 1.1 and call *changeVersion("1.0", "1.1")*
>
> But the next time my app runs it's not gonna open the database, instead
> it'll give me an error "*Version mismatch*", because now the database ini
> says that the database version is *1.1*, not *1.0.*
>
> And if I just change the open parameters to send *"1.1"*, it's not gonna
> even open in the first run, giving the same error, because ini file will
> say that the version is *1.0*, not *1.1.*
>
> To workaround this issue I'm just playing around with my own version
> control, and ignoring the builtin QML solution.
>
> But it looks wrong =/
> Probably I'm missing something and couldn't understand correctly.
> Does anyone can help me find out a good solution?
>
> Best,
> Daniel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151023/0e97d0f5/attachment.html>


More information about the Interest mailing list