Skip to content

Commit

Permalink
fixed db versionning problem
Browse files Browse the repository at this point in the history
  • Loading branch information
remjey committed Mar 25, 2018
1 parent b21fcfb commit 09a82f8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
33 changes: 23 additions & 10 deletions qml/Model.qml
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,22 @@ QtObject {
property string cfgOpenBinaryAsText: "open.binary.as.text"
property string cfgHistoryGoBackIfSelectorExists: "history.go.back.if.selector.exists"

property var dbVersions: [ "", "0.1", "0.2", "0.3" ];

Component.onCompleted: {
_db = LocalStorage.openDatabaseSync("Gopherette", "", "Gopherette Settings", 100000);
if (_db.version === "") {
_db.changeVersion("", "0.1", function (tx) {

var dbVersions = [
{ from: "", to: "0.1", upgrade: function (tx) {
tx.executeSql("create table bookmarks (id integer primary key autoincrement, name text not null, host text not null, port integer not null default 70, type text not null default '1', selector text not null default '')");
tx.executeSql("insert into bookmarks (name, host, port) values ('Floodgap', 'gopher.floodgap.com', 70)");
});
}
if (_db.version === "0.1") {
_db.changeVersion("0.1", "0.2", function (tx) {
}},
{ from: "0.1", to: "0.2", upgrade: function (tx) {
tx.executeSql("create table settings (k text primary key, v text)");
tx.executeSql("insert into settings (k, v) values (?, ?)", [ "font.size.landscape", Theme.fontSizeSmall ]);
tx.executeSql("insert into settings (k, v) values (?, ?)", [ "font.size.portrait", Theme.fontSizeSmall ]);
});
}
if (_db.version === "0.2") {
_db.changeVersion("0.2", "0.3", function (tx) {
}},
{ from: "0.2", to: "0.3", upgrade: function (tx) {
tx.executeSql("delete from settings");
tx.executeSql("alter table settings add ord real not null default 0");
tx.executeSql("insert into settings (k, v, ord) values (?, ?, 1)", [ cfgPortraitReflow, "true" ]);
Expand All @@ -123,6 +122,20 @@ QtObject {
tx.executeSql("insert into settings (k, v, ord) values (?, ?, 4)", [ cfgLandscapeRawFontSize, "19" ]);
tx.executeSql("insert into settings (k, v, ord) values (?, ?, 5)", [ cfgOpenBinaryAsText, "false" ]);
tx.executeSql("insert into settings (k, v, ord) values (?, ?, 6)", [ cfgHistoryGoBackIfSelectorExists, "false" ]);
}},
]

var latestDbVersion = dbVersions[dbVersions.length - 1].to;
if (_db.version !== dbVersions[dbVersions.length]) {
var currentDbVersion = _db.version;
_db.changeVersion(currentDbVersion, latestDbVersion, function (tx) {
dbVersions.every(function (v) {
if (currentDbVersion === v.from) {
v.upgrade(tx);
currentDbVersion = v.to;
}
return true;
});
});
}

Expand Down
3 changes: 3 additions & 0 deletions rpm/harbour-gopherette.changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# * date Author's Name <author's email> version-release
# - Summary of changes

* Sun Mar 26 2018 Jérémy Farnaud <jf@almel.fr> 0.3-2
- Fixed DB versionning problems

* Sun Mar 25 2018 Jérémy Farnaud <jf@almel.fr> 0.3-1
- First public release

2 changes: 1 addition & 1 deletion rpm/harbour-gopherette.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Name: harbour-gopherette
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Gopherette
Version: 0.3
Release: 1
Release: 2
Group: Qt/Qt
License: GPL-3
URL: http://jf.almel.fr/gopherette/
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-gopherette.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Name: harbour-gopherette
Summary: Gopherette
Version: 0.3
Release: 1
Release: 2
# The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS
Group: Qt/Qt
Expand Down
8 changes: 4 additions & 4 deletions translations/harbour-gopherette-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<source>About Gopherette</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gopherette is a Free Software developped by Jérémy Farnaud and released under the GNU GPLv3 license.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Links</source>
<translation type="unfinished"></translation>
Expand All @@ -31,5 +27,9 @@
<source>License</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gopherette is Free Software developped by Jérémy Farnaud and released under the GNU GPLv3 license.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
8 changes: 4 additions & 4 deletions translations/harbour-gopherette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<source>About Gopherette</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gopherette is a Free Software developped by Jérémy Farnaud and released under the GNU GPLv3 license.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Links</source>
<translation type="unfinished"></translation>
Expand All @@ -31,5 +27,9 @@
<source>License</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Gopherette is Free Software developped by Jérémy Farnaud and released under the GNU GPLv3 license.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

0 comments on commit 09a82f8

Please sign in to comment.