Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Linus Jahn
kaidan
Commits
76b1ddfd
Commit
76b1ddfd
authored
Jun 18, 2017
by
Linus Jahn
Committed by
GitHub
Jun 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Database: Add new roster row `avatarHash` (#112)
parent
2e2ae1d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
src/Database.cpp
src/Database.cpp
+15
-3
src/Database.h
src/Database.h
+1
-0
No files found.
src/Database.cpp
View file @
76b1ddfd
...
...
@@ -30,7 +30,7 @@
#include <QSqlQuery>
#include <QSqlRecord>
static
const
unsigned
int
DATABASE_LATEST_VERSION
=
2
;
static
const
unsigned
int
DATABASE_LATEST_VERSION
=
3
;
static
const
char
*
DATABASE_TABLE_INFO
=
"dbinfo"
;
static
const
char
*
DATABASE_TABLE_MESSAGES
=
"Messages"
;
static
const
char
*
DATABASE_TABLE_ROSTER
=
"Roster"
;
...
...
@@ -117,7 +117,9 @@ void Database::convertDatabase()
createNewDatabase
();
break
;
case
1
:
convertDatabaseToV2
();
convertDatabaseToV2
();
version
=
2
;
case
2
:
convertDatabaseToV3
();
version
=
3
;
// only break on last convertion step, to not enter default (!)
break
;
default:
...
...
@@ -157,7 +159,8 @@ void Database::createNewDatabase()
"'lastOnline' TEXT,"
// < UNUSED v
"'activity' TEXT,"
"'status' TEXT,"
"'mood' TEXT"
// < UNUSED ^
"'mood' TEXT,"
"'avatarHash' TEXT"
// < UNUSED ^
")"
))
{
qFatal
(
"Failed to query database: %s"
,
qPrintable
(
query
.
lastError
().
text
()));
...
...
@@ -207,3 +210,12 @@ void Database::convertDatabaseToV2()
// create a new dbinfo table
createDbInfoTable
();
}
void
Database
::
convertDatabaseToV3
()
{
QSqlQuery
query
(
database
);
query
.
prepare
(
"ALTER TABLE Roster ADD avatarHash TEXT"
);
if
(
!
query
.
exec
())
{
qFatal
(
"Failed to query database: %s"
,
qPrintable
(
query
.
lastError
().
text
()));
}
}
src/Database.h
View file @
76b1ddfd
...
...
@@ -41,6 +41,7 @@ private:
void
createDbInfoTable
();
void
createNewDatabase
();
void
convertDatabaseToV2
();
void
convertDatabaseToV3
();
QSqlDatabase
database
;
int
version
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment